[Python] Moving Python graphics.py objects

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to move two objects at the same time in python graphics (This seems to be referring to John Zelle's graphics.py), then repeat the movement in a loop. However when I try to loop it, the shapes disappear. How can I fix this?

    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()

    Continue reading...

Compartilhe esta Página