Table Of Contents
Animation¶
Animation and AnimationTransition are used to animate Widget properties. You must specify (minimum) a property name and target value. To use Animation, follow these steps:
- Setup an Animation object
- Use the Animation object on a Widget
Simple animation¶
To animate a Widget’s x or y position, simply specify the target x/y values where you want the widget positioned at the end of the animation:
anim = Animation(x=100, y=100)
anim.start(widget)
The animation will last for 1 second unless duration is specified. When anim.start() is called, the Widget will move smoothly from the current x/y position to (100, 100).
Multiple properties and transitions¶
You can animate multiple properties and use built-in or custom transition functions using transition (or t= shortcut). For example, to animate the position and size using the ‘in_quad’ transition:
anim = Animation(x=50, size=(80, 80), t='in_quad')
anim.start(widget)
Note that the t= parameter can be the string name of a method in the AnimationTransition class, or your own animation function.
Sequential animation¶
To join animations sequentially, use the ‘+’ operator. The following example will animate to x=50 over 1 second, then animate size to (80, 80) over the next two seconds:
anim = Animation(x=50) + Animation(size=(80, 80), duration=2.)
anim.start(widget)
Parallel animation¶
To join animations in parallel, use the ‘&’ operator. The following example will animate position to (80, 10) over 1 second, while in parallel animating the first half of size=(800, 800):
anim = Animation(pos=(80, 10))
anim &= Animation(size=(800, 800), duration=2.)
anim.start(widget)
- class kivy.animation.Animation(**kw)¶
Bases: kivy.event.EventDispatcher
Create an animation definition that can be used to animate a Widget
Parameters : - duration or d: float, default to 1.
Duration of the animation, in seconds
- transition or t: str or func
Transition function for animate properties. It can be the name of a method from AnimationTransition
- step or s: float
Step in milliseconds of the animation. Default to 1 / 60.
Events : - on_start: widget
Fired when the animation is started on a widget
- on_complete: widget
Fired when the animation is completed or stopped on a widget
- on_progress: widget, progression
Fired when the progression of the animation is changing
Changed in version 1.4.0: Added s/step parameter.
- animated_properties¶
Return the properties used to animate
- cancel(widget)¶
Cancel the animation previously applied on a widget. Same effect as stop, except the on_complete event will not be triggered!
New in version 1.4.0.
- static cancel_all(widget, *largs)¶
Cancel all animations that concern a specific widget / list of properties. see cancel
Example:
anim = Animation(x=50) anim.start(widget) # and later Animation.cancel_all(widget, 'x')
New in version 1.4.0.
- cancel_property(widget, prop)¶
Even if an animation is running, remove a property. It will not be animated further. If it was the only/last property being animated on. the widget, the animation will be canceled (see cancel)
New in version 1.4.0.
- duration¶
Return the duration of the animation
- start(widget)¶
Start the animation on a widget
- stop(widget)¶
Stop the animation previously applied on a widget, triggering on_complete event
- static stop_all(widget, *largs)¶
Stop all animations that concern a specific widget / list of properties.
Example:
anim = Animation(x=50) anim.start(widget) # and later Animation.stop_all(widget, 'x')
- stop_property(widget, prop)¶
Even if an animation is running, remove a property. It will not be animated further. If it was the only/last property being animated on. the widget, the animation will be stopped (see stop)
- transition¶
Return the transition of the animation
- class kivy.animation.AnimationTransition¶
Bases: object
Collection of animation function, to be used with Animation object. Easing Functions ported into Kivy from Clutter Project http://www.clutter-project.org/docs/clutter/stable/ClutterAlpha.html
progress parameter in each animation functions is between 0-1 range.
- static in_back(progress)¶
- static in_bounce(progress)¶
- static in_circ(progress)¶
- static in_cubic(progress)¶
- static in_elastic(progress)¶
- static in_expo(progress)¶
- static in_out_back(progress)¶
- static in_out_bounce(progress)¶
- static in_out_circ(progress)¶
- static in_out_cubic(progress)¶
- static in_out_elastic(progress)¶
- static in_out_expo(progress)¶
- static in_out_quad(progress)¶
- static in_out_quart(progress)¶
- static in_out_quint(progress)¶
- static in_out_sine(progress)¶
- static in_quad(progress)¶
- static in_quart(progress)¶
- static in_quint(progress)¶
- static in_sine(progress)¶
- static linear(progress)¶
- static out_back(progress)¶
- static out_bounce(progress)¶
- static out_circ(progress)¶
- static out_cubic(progress)¶
- static out_elastic(progress)¶
- static out_expo(progress)¶
- static out_quad(progress)¶
- static out_quart(progress)¶
- static out_quint(progress)¶
- static out_sine(progress)¶