kivy/examples/animation/animate.py

38 lines
984 B
Python
Raw Normal View History

2011-06-19 17:42:40 +00:00
'''
Widget animation
================
This is showing an example of a animation creation, and how you can apply yo a
widget.
'''
import kivy
kivy.require('1.0.7')
2011-01-11 01:36:46 +00:00
from kivy.animation import Animation
2011-06-19 17:42:40 +00:00
from kivy.app import App
from kivy.uix.button import Button
2011-01-11 01:36:46 +00:00
class TestApp(App):
2011-06-19 17:42:40 +00:00
2011-01-11 01:36:46 +00:00
def animate(self, instance):
2011-06-19 17:42:40 +00:00
# create an animation object.
2011-01-11 01:36:46 +00:00
animation = Animation(pos=(100, 100), t='out_bounce')
animation += Animation(pos=(200, 100), t='out_bounce')
animation &= Animation(size=(500, 500))
animation += Animation(size=(100, 50))
2011-06-19 17:42:40 +00:00
# apply the animation on the button, passed in the "instance" argument
2011-01-11 01:36:46 +00:00
animation.start(instance)
def build(self):
2011-06-19 17:42:40 +00:00
# create a button, and attach animate() method as a on_press handler
2011-01-31 21:37:48 +00:00
button = Button(size_hint=(None, None), text='plop')
2011-01-11 01:36:46 +00:00
button.bind(on_press=self.animate)
return button
2011-06-19 17:42:40 +00:00
if __name__ in ('__main__', '__android__'):
TestApp().run()
2011-01-11 01:36:46 +00:00