def __init__(self):
...
self.sleepTime = 20
self.isStopped = False
self.window = window
self.window.after(self.sleepTime, self.animate)
window.mainloop()
...
def animate(self):
if not self.isStopped:
self.canvas.update()
self.canvas.delete("ball")
for ball in self.ballList:
self.redisplayBall(ball)
self.window.after(self.sleepTime, self.animate)