我正在使用python的turtle库编写一个简单的弹跳模拟。使用乌龟的write方法时,屏幕会出现闪烁的麻烦(当我取消注释注释时,就会发生闪烁)。有人可以解释为什么我的代码会如此表现以及如何解决此问题吗?非常感谢。
def draw(self):
turtle.clear()
width, height = self.size
turtle.penup()
turtle.goto(-width//2, height//2)
turtle.pendown()
turtle.goto(width//2, height//2)
turtle.goto(width//2, -height//2)
turtle.goto(-width//2, -height//2)
turtle.goto(-width//2, height//2)
# hours_text = "Hours " + str(self.hours)
# turtle.write(hours_text, False)
# turtle.penup()
# turtle.goto(0, height//2)
# infections_text = "Infected " + str(self.count_infected())
# turtle.write(infections_text, False)
for person in self.people:
person.draw()