from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.animation import Animation
class MyApp(App):
def build(self):
layout = BoxLayout(orientation='vertical')
button = Button(text='Rotate Me', size_hint=(None, None), size=(200, 100))
layout.add_widget(button)
def on_button_click(instance):
anim = Animation(angle=360, duration=1)
anim.bind(on_complete=self.reset_angle)
anim.start(button)
button.bind(on_release=on_button_click)
return layout
def reset_angle(self, *args):
button = args[1]
button.angle = 0
if __name__ == '__main__':
MyApp().run()