参考John Zelle 的 graphics.py,我希望在对象到达窗口边缘并且看不见GraphWin
之后立即关闭。Circle
以下代码创建一个圆圈并移动它:
win = GraphWin("My Circle", 100, 100)
c = Circle(Point(50,50), 10)
c.draw(win)
for i in range(40):
c.move(30, 0) #speed=30
time.sleep(1)
#c should move until the end of the windows(100),
win.close() # then windows of title "My Circle" should close immediately
有没有办法做到这一点,而不是使用range
和计算其确切的“步数”?