[Python] Turtle - screen.update() not working with copy method?

Discussão em 'Python' iniciado por Stack, Fevereiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list with several turtle instances. I want to create a copy of one object and let this one move forward.

    This works fine. But when I disable screen udpates and do it manually in my code it gives me a different result and I don't see the turtle on its new position. But I do see that it has moved there.

    Here is an example. This produces the expected output. But as soon as I disable tracer and do a manual update it behaves weirdly.

    from turtle import Screen, Turtle
    from copy import copy


    screen = Screen()
    screen.setup(width=250, height=250)
    #screen.tracer(0)

    turtles = [Turtle(), Turtle()]

    for i in range(10):
    #screen.update()

    new_turtle = copy(turtles[0])

    new_turtle.forward(10)
    turtles.append(new_turtle)

    screen.exitonclick()

    Continue reading...

Compartilhe esta Página