移动Python graphics.py对象

2024-06-25 23:21:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在python图形中同时移动两个对象(这似乎是指John Zelle's graphics.py),然后在循环中重复移动。不过,当我试图循环它,形状消失。我该怎么解决?

def main():
    win = GraphWin('Lab Four', 400, 400)
    c = Circle(Point(100, 50), 40)
    c.draw(win)
    c.setFill('red')
    s = Rectangle(Point(300, 300), Point(350, 350))
    s.draw(win)
    s.setFill('blue')
    s.getCenter()
    while not c.getCenter() == Circle(Point(400, 50), 40):
        c.move(10, 0)
        s.move(-10, 0)
    win.getMouse
    while not (win.checkMouse()):
        continue
    win.close()

Tags: 对象py图形movenotjohnwinpoint