Skip to content

Commit d12b778

Browse files
committed
new expressive MDExCircularProgressIndicator and MDExLinearProgressIndicator
1 parent d668d8b commit d12b778

File tree

10 files changed

+1248
-116
lines changed

10 files changed

+1248
-116
lines changed

examples/exprogressindicator.py

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
from kivy.animation import Animation
2+
from kivy.clock import Clock
3+
from kivy.lang import Builder
4+
from kivy.properties import BooleanProperty, StringProperty
5+
6+
from examples.common_app import CommonApp
7+
from kivymd.app import MDApp
8+
from kivymd.uix.boxlayout import MDBoxLayout
9+
10+
KV = """
11+
<SelectedItem>
12+
adaptive_size: True
13+
spacing: "12dp"
14+
15+
MDCheckbox:
16+
on_active: root.dispatch("on_active", self.active)
17+
active:
18+
root.active
19+
20+
MDLabel:
21+
text: root.text
22+
theme_line_height: "Custom"
23+
adaptive_size: True
24+
pos_hint: {'center_y': .5}
25+
line_height: 1
26+
27+
28+
MDScreen:
29+
md_bg_color: self.theme_cls.backgroundColor
30+
31+
MDIconButton:
32+
on_release: app.open_menu(self)
33+
pos_hint: {"top": .98}
34+
x: dp(12)
35+
icon: "menu"
36+
37+
BoxLayout:
38+
spacing: "24dp"
39+
40+
41+
BoxLayout:
42+
spacing:dp(10)
43+
orientation:"vertical"
44+
padding:[dp(50), dp(80), 0, dp(20)]
45+
46+
BoxLayout:
47+
orientation:"vertical"
48+
MDLabel:
49+
text: "Progress (0-100)"
50+
adaptive_height: True
51+
MDSlider:
52+
min:0
53+
max:100
54+
step: 1
55+
value:50
56+
on_value:
57+
linear_indicator_horizontal.value = self.value
58+
linear_indicator_vertical.value = self.value
59+
circular_indicator.value = self.value
60+
MDSliderHandle:
61+
MDSliderValueLabel:
62+
63+
64+
BoxLayout:
65+
orientation:"vertical"
66+
MDLabel:
67+
text: "Amplitude (0 - 30) dp"
68+
adaptive_height: True
69+
MDSlider:
70+
min:dp(0)
71+
max:dp(30)
72+
step: 1
73+
value:dp(3)
74+
on_value:
75+
linear_indicator_horizontal.amplitude = self.value
76+
linear_indicator_vertical.amplitude = self.value
77+
circular_indicator.amplitude = self.value
78+
MDSliderHandle:
79+
80+
BoxLayout:
81+
orientation:"vertical"
82+
MDLabel:
83+
text: "Wavelenght (0 - 100) dp"
84+
adaptive_height: True
85+
MDSlider:
86+
min:dp(0)
87+
max:dp(100)
88+
step: 2
89+
value:dp(10)
90+
on_value:
91+
linear_indicator_horizontal.wave_length = self.value
92+
linear_indicator_vertical.wave_length = self.value
93+
circular_indicator.wave_length = self.value
94+
MDSliderHandle:
95+
96+
BoxLayout:
97+
orientation:"vertical"
98+
MDLabel:
99+
text: "Wave speed (-50 - 50) dp/s"
100+
adaptive_height: True
101+
MDSlider:
102+
min:dp(-50)
103+
max:dp(50)
104+
step: 2
105+
value:dp(20)
106+
on_value:
107+
linear_indicator_horizontal.wave_speed = self.value
108+
linear_indicator_vertical.wave_speed = self.value
109+
circular_indicator.wave_speed = self.value
110+
MDSliderHandle:
111+
112+
BoxLayout:
113+
orientation:"vertical"
114+
MDLabel:
115+
text: "Thickness (4 - 20) dp"
116+
adaptive_height: True
117+
118+
MDSlider:
119+
min:dp(4)
120+
max:dp(20)
121+
step: 1
122+
value:dp(4)
123+
on_value:
124+
linear_indicator_horizontal.thickness = self.value
125+
linear_indicator_vertical.thickness = self.value
126+
circular_indicator.thickness = self.value
127+
MDSliderHandle:
128+
MDSliderValueLabel:
129+
130+
BoxLayout:
131+
orientation:"vertical"
132+
MDLabel:
133+
text: "Circular indicator size (20 - 200)dp"
134+
adaptive_height: True
135+
136+
MDSlider:
137+
min:dp(20)
138+
max:dp(240)
139+
step: 2
140+
value:box.size[0]
141+
on_value:
142+
box.size = [self.value]*2
143+
MDSliderHandle:
144+
MDSliderValueLabel:
145+
146+
BoxLayout:
147+
spacing: "24dp"
148+
orientation:"vertical"
149+
padding:dp(20)
150+
151+
MDLabel:
152+
id:fps
153+
padding:[dp(10), 0]
154+
halign:"center"
155+
text:"FPS:"
156+
adaptive_size:True
157+
158+
AnchorLayout:
159+
BoxLayout:
160+
id:box
161+
size_hint: None, None
162+
size: [dp(50)]*2
163+
164+
MDExCircularProgressIndicator:
165+
id: circular_indicator
166+
active: False
167+
168+
MDExLinearProgressIndicator:
169+
color_array: [[1.0, 0.0, 0.0, 1.0], [1.0, 0.5, 0.0, 1.0], [1.0, 0.9, 0.0, 1.0], [0.0, 0.8, 0.3, 1.0], [0.0, 0.5, 1.0, 1.0], [0.6, 0.2, 0.8, 1.0]]
170+
id: linear_indicator_horizontal
171+
172+
MDExLinearProgressIndicator:
173+
id: linear_indicator_vertical
174+
color_array: [[0.0, 0.4, 0.4, 1.0], [0.0, 0.7, 0.6, 1.0], [0.2, 0.8, 0.8, 1.0], [0.3, 0.5, 0.9, 1.0], [0.1, 0.2, 0.5, 1.0]]
175+
orientation: "vertical"
176+
size_hint_y: None
177+
height: self.width
178+
179+
BoxLayout:
180+
spacing: "12dp"
181+
size_hint_y:None
182+
height:dp(50)
183+
184+
Widget:
185+
MDLabel:
186+
text:"Determinate"
187+
adaptive_size:True
188+
Switch:
189+
size_hint_x:None
190+
size:[dp(100),dp(50)]
191+
on_active:
192+
linear_indicator_horizontal.determinate = self.active
193+
linear_indicator_vertical.determinate = self.active
194+
Widget:
195+
196+
BoxLayout:
197+
spacing: "12dp"
198+
size_hint_y:None
199+
height:dp(50)
200+
201+
Widget:
202+
MDLabel:
203+
text:"Disjoint | Contiguous"
204+
adaptive_size:True
205+
Switch:
206+
size_hint_x:None
207+
size:[dp(100),dp(50)]
208+
on_active:
209+
linear_indicator_horizontal.indeterminate_animator = "discontinuous" if self.active else ""
210+
linear_indicator_vertical.indeterminate_animator = "discontinuous" if self.active else ""
211+
Widget:
212+
213+
"""
214+
215+
216+
class SelectedItem(MDBoxLayout):
217+
active = BooleanProperty(False)
218+
text = StringProperty()
219+
220+
def __init__(self, *args, **kwargs):
221+
super().__init__(*args, **kwargs)
222+
self.register_event_type("on_active")
223+
224+
def on_active(self, *args): ...
225+
226+
227+
class Example(MDApp, CommonApp):
228+
229+
def build(self):
230+
self.theme_cls.primary_palette = "Olive"
231+
self.theme_cls.theme_style = "Dark"
232+
return Builder.load_string(KV)
233+
234+
def on_start(self):
235+
Clock.schedule_interval(self.set_fps, 0.5)
236+
237+
def set_fps(self, dt):
238+
self.root.ids.fps.text = f"FPS: {Clock.get_rfps()}"
239+
240+
def disabled_widgets(self): ...
241+
242+
243+
Example().run()

examples/md_transitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def on_start(self):
5353
"easing_accelerated",
5454
"easing_decelerated",
5555
"easing_standard",
56-
"in_out_cubic",
56+
"easing_emphasized",
5757
]: # Add more here for comparison
5858
print(transition)
5959
widget = AnimBox()

0 commit comments

Comments
 (0)