kivy/examples/animation/animate.py

36 lines
942 B
Python
Raw Normal View History

2011-06-19 17:42:40 +00:00
'''
Widget animation
================
2014-01-26 07:39:24 +00:00
This is an example of an animation creation, and how you can apply it to a
2011-06-19 17:42:40 +00:00
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
button = Button(size_hint=(None, None), text='plop', on_press=self.animate)
2011-01-11 01:36:46 +00:00
return button
if __name__ == '__main__':
2011-06-19 17:42:40 +00:00
TestApp().run()