Table Of Contents
Touch Ripple¶
New in version 1.10.1.
Warning
This code is still experimental, and its API is subject to change in a future version.
This module contains mixin classes to add a touch ripple visual effect known from Google Material Design <https://en.wikipedia.org/wiki/Material_Design>_ to widgets.
For an overview of behaviors, please refer to the behaviors
documentation.
The class TouchRippleBehavior provides
rendering the ripple animation.
The class TouchRippleButtonBehavior
basically provides the same functionality as
ButtonBehavior but rendering the ripple
animation instead of default press/release visualization.
- class kivy.uix.behaviors.touchripple.TouchRippleBehavior(**kwargs)¶
Bases:
builtins.objectTouch ripple behavior.
Supposed to be used as mixin on widget classes.
Ripple behavior does not trigger automatically, concrete implementation needs to call
ripple_show()respectiveripple_fade()manually.Example¶
Here we create a Label which renders the touch ripple animation on interaction:
class RippleLabel(TouchRippleBehavior, Label): def __init__(self, **kwargs): super(RippleLabel, self).__init__(**kwargs) def on_touch_down(self, touch): collide_point = self.collide_point(touch.x, touch.y) if collide_point: touch.grab(self) self.ripple_show(touch) return True return False def on_touch_up(self, touch): if touch.grab_current is self: touch.ungrab(self) self.ripple_fade() return True return False
- ripple_fade()¶
Finish ripple animation on current widget.
- ripple_show(touch)¶
Begin ripple animation on current widget.
Expects touch event as argument.
- class kivy.uix.behaviors.touchripple.TouchRippleButtonBehavior(**kwargs)¶
Bases:
kivy.uix.behaviors.touchripple.TouchRippleBehaviorThis mixin class provides a similar behavior to
ButtonBehaviorbut provides touch ripple animation instead of button pressed/released as visual effect.- Events:
- on_press
Fired when the button is pressed.
- on_release
Fired when the button is released (i.e. the touch/click that pressed the button goes away).