I’m using kivy to develop a small project. Currently, I use the animation utility to animate Widgets (change size). Everything works great so far, but I have no idea how I am supposed to stop animations and continue other code lines.
It is code that I try
class Animination:
def __init__(self):
self.anim_zoom_in = None
self.anim_zoom_out = None
def animate_zoom(self, target_widget):
anim_zoom_in = Animation(width=dp(60), height=dp(80), duration=1)
anim_zoom_out = Animation(width=dp(80), height=dp(100), duration=1)
anim_zoom_in.bind(on_complete=lambda *x: anim_zoom_out.start(target_widget))
anim_zoom_out.bind(on_complete=lambda *x: anim_zoom_in.start(target_widget))
anim_zoom_in.start(target_widget)
def stop_animation(self, target_widget):
if self.anim_zoom_in:
self.anim_zoom_in.unbind(on_complete=None)
self.anim_zoom_in.cancel(target_widget)
if self.anim_zoom_out:
self.anim_zoom_out.unbind(on_complete=None)
self.anim_zoom_out.cancel(target_widget)
I am trying to stop by calling stop_animating function.But it is still running.