Introduction to Animation Framework
| Animation Framework | Types of Animations |
In this document
The Animation Class
In PyMT to animate a widget you first create a Animation Object. All the properties that has to be animated is passed to this object along with the duration for which the animation has to take place. Lets start with a simple example
win = MTWindow()
widget = MTScatterWidget()
win.add_widget(widget)
animobj = Animation(duration = 3, rotation = 270)
widget.do(animobj)
runTouchApp()
The above example rotates the widget 270 degrees in 3 secs. There are two points to note here:
- duration is in seconds. you can either use the name duration = 3 or d = 3
- The animation is only executed when you call do() method by the widget, you can also use animobj.animate(widget)
You can also pass in any number of parameters that you want to be animated simultaneously. For example
The above animation object can handle all three properties simultaneously.
Events generated
When the animation is executed there are two events which are generated
- on_start - Fired on start of the animation
- on_complete - Fired when the animation is completed
both the events also returns the widget which executed the animation. Check api doc to understand the structure of the event.
On completion of execution of the animation the widget fires a on_animation_complete event. In the event you also obtain the reference to the animation object; which can be useful for comparing which animation was completed when there are several animations executing simultaneously in a widget.
