Turtle Screen.tracer(0) 不会停止所有动画

Turtle Screen.tracer(0) doesn't stop all animation

我想在 Python Turtle Graphics 中使用 Screen.tracer(0) 禁用动画。但是在下面的程序中,如果您注释掉 screen.update(),仍然会发生一些动画 - 虽然海龟没有“移动”(或更新),但海龟轨迹会被绘制出来。请问这是怎么回事?有没有办法让更新屏幕完全手动?

import turtle

def move():
    my_turtle.forward(1)
    my_turtle.right(1)
    screen.update()  # Comment out this line to see issue.
    screen.ontimer(move, 10)

screen = turtle.Screen()
my_turtle = turtle.Turtle()
my_turtle.shape("turtle")
screen.tracer(0)
move()
turtle.done()

不,screen.tracer(0) 不会停止所有动画。一些 turtle 命令,如 end_fill() 直接调用 screen.update(),一些像 dot() 调用它是因为它们依次调用其他方法。你只是在调用系统时提示update(),而不是完全控制它。

将您的 update() 调用放在您认为需要它们的地方,并且不要假设某些方法会强制更新,否则 turtle 的未来更新可能会破坏您的代码。 (即有人可能真的修好了乌龟。)

有关可能有用的详细信息,请参阅我的 and information about the first argument's numeric value

在turtle.py中,forward()调用_go()设置端点,然后调用_goto()

_goto() 创建换行符 如果线段超过 42

if len(self.currentLine) > 42: # 42! answer to the ultimate question
                               # of life, the universe and everything
    self._newLine()

该值似乎是任意的;您可以将其设置为更高的值,但随后会出现停顿,似乎什么也没有发生。

def _newLine(self, usePos=True):
    """Closes current line item and starts a new one.
       Remark: if current line became too long, animation
       performance (via _drawline) slowed down considerably.
    """