LoadingIndicator#
#
Loading indicators display the status of a process using continuous or sequential shape animations.
Used to represent indeterminate operations (no fixed end).
Each shape is based on Material 3 geometry guidelines.
Animations can cycle between multiple predefined shapes.
Usage#
from kivy.clock import Clock
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
MDScreen:
md_bg_color: app.theme_cls.surfaceColor
MDLoadingIndicator:
id: indicator
shape_size: dp(100)
'''
class ExampleApp(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
# start the morphing animation
self.root.ids.indicator.start()
# print available shape names
print(self.root.ids.indicator.get_shape_names())
# optionally stop animation after 5 seconds
# Clock.schedule_once(self.root.ids.indicator.stop, 5)
ExampleApp().run()
from kivymd.app import MDApp
from kivymd.uix.screen import MDScreen
from kivymd.uix.loadingindicator import MDLoadingIndicator
class ExampleApp(MDApp):
def build(self):
return MDScreen(
MDLoadingIndicator(
id="indicator",
shape_size="100dp",
),
md_bg_color=self.theme_cls.surfaceColor,
)
def on_start(self):
# start the morphing animation
self.root.children[0].start()
# print available shape names
print(self.root.children[0].get_shape_names())
# optionally stop animation after 5 seconds
# Clock.schedule_once(self.root.ids.indicator.stop, 5)
ExampleApp().run()
API - kivymd.uix.loadingindicator.loadingindicator#
- class kivymd.uix.loadingindicator.loadingindicator.MDLoadingIndicator(*args, **kwargs)#
Implementation of a morphing and rotating loading indicator.
For more information, see the
AnchorLayoutandRotateBehaviorclasses documentation.- shape#
Current shape name displayed by the loading indicator.
The shape corresponds to one of the predefined shapes available in the
MaterialShapelibrary.You can view all available shape names using
get_shape_names().shapeis aStringPropertyand defaults to ‘cookie12Sided’.
- shape_sequence#
Sequence of shape names through which the indicator cycles.
Each shape in the list is morphed into the next one over time, looping continuously while the indicator is active.
shape_sequenceis aListPropertyand defaults to:[ "cookie12Sided", "pentagon", "pill", "verySunny", "cookie4Sided", "oval", "flower", "softBoom", ]
- shape_size#
Size of the loading indicator.
shape_sizeis aNumericPropertyand defaults to dp(48).
- duration#
Duration of one morph-and-rotate cycle in seconds.
This value controls the overall speed of the loading indicator.
durationis aNumericPropertyand defaults to 0.65.
- active_indicator_color#
Color of the active (foreground) loading shape.
active_indicator_coloris aColorPropertyand defaults to None.
- container_color#
Background container color of the indicator.
container_coloris aColorPropertyand defaults to None.
- shape_index#
Current index in the
shape_sequence.shape_indexis aNumericPropertyand defaults to 0.
- start(*args)#
Start the loading animation.
Initiates the shape morphing and rotation cycle. The indicator continuously transitions between the shapes defined in
shape_sequencewhile rotating at regular intervals.If already active, the animation sequence is reset.
- stop(*args)#
Stop the loading animation.
- get_shape_names()#
Return all available material shape names.