window.mainloop如果不按下
stop按钮,将永远不会执行主应用程序循环。这是您问题的根源。重写动画循环:
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)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)