Magic#
Magical effects for buttons. Warning Magic effects do not work correctly with KivyMD buttons! To apply magic effects, you must create a new class that is inherited from the
widget to which you apply the effect and from the In KV file: In python file: The Example:MagicBehavior
class.<MagicButton@MagicBehavior+MDRectangleFlatButton>
class MagicButton(MagicBehavior, MDRectangleFlatButton):
pass
MagicBehavior
class provides five effects:
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
<MagicButton@MagicBehavior+MDRectangleFlatButton>
MDFloatLayout:
MagicButton:
text: "WOBBLE EFFECT"
on_release: self.wobble()
pos_hint: {"center_x": .5, "center_y": .3}
MagicButton:
text: "GROW EFFECT"
on_release: self.grow()
pos_hint: {"center_x": .5, "center_y": .4}
MagicButton:
text: "SHAKE EFFECT"
on_release: self.shake()
pos_hint: {"center_x": .5, "center_y": .5}
MagicButton:
text: "TWIST EFFECT"
on_release: self.twist()
pos_hint: {"center_x": .5, "center_y": .6}
MagicButton:
text: "SHRINK EFFECT"
on_release: self.shrink()
pos_hint: {"center_x": .5, "center_y": .7}
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
API - kivymd.uix.behaviors.magic_behavior
#
- class kivymd.uix.behaviors.magic_behavior.MagicBehavior#
- magic_speed#
Animation playback speed.
magic_speed
is aNumericProperty
and defaults to 1.
- grow(self)#
Grow effect animation.
- shake(self)#
Shake effect animation.
- wobble(self)#
Wobble effect animation.
- twist(self)#
Twist effect animation.
- shrink(self)#
Shrink effect animation.
- on_touch_up(self, *args)#