Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gottadiveintopython/93e234d3af0de44ed5730e920e6d8a8b to your computer and use it in GitHub Desktop.

Select an option

Save gottadiveintopython/93e234d3af0de44ed5730e920e6d8a8b to your computer and use it in GitHub Desktop.
"Animation._instances" keeps getting fat
'''
https://youtu.be/P2WtjZAWc8I
'''
from kivy.app import App
from kivy.factory import Factory
from kivy.animation import Animation
from kivy.clock import Clock
import itertools
anim_id_iter = itertools.count()
def start_new_animation(dt):
print("len(Animation._instances) ==", len(Animation._instances))
print(f"start {next(anim_id_iter)}th animation")
w = Factory.Widget()
anim1 = Animation(x=100)
anim2 = Animation(y=200)
(anim1 & anim2).start(w)
Clock.schedule_once(lambda dt: anim1.cancel(w), .5)
class SampleApp(App):
def build(self):
return Factory.Widget()
def on_start(self):
Clock.schedule_interval(start_new_animation, 1)
SampleApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment