本文介绍了海龟示踪剂参数示例麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Turtle.tracer 的具体用法是什么?在 python 文档中,它被写成 Turn turtle animation on/off and set delay for update graphics. 我用它来禁用动画但参数不清楚,例如在这段代码中,如果我使用了turtle.trace turtle没有绘制表格的其余部分如何设置正确的参数.

What is the exact usage of Turtle.tracer? In python docs it is written Turn turtle animation on/off and set delay for update drawings. I use it for disabling animation but the arguments are not clear for example in this code if I use turtle.trace turtle doesn't draw rest of table how to set correct arguments.

import turtle
turtle.width(5)
yd=xd=-64
turtle.tracer(8,25)#This is the problem
for i in range(2):
    turtle.up()
    turtle.goto(-197.5,yd)
    turtle.down()
    turtle.seth(0)
    turtle.fd(394)
    yd+=128
    turtle.up()
    turtle.goto(xd,197.5)
    turtle.down()
    turtle.seth(270)
    turtle.fd(394)
    xd+=128

推荐答案

使用 turtle.delay(0):

import turtle
turtle.width(5)
yd=xd=-64
turtle.delay(0) # <----
for i in range(2):
    turtle.up()
    turtle.goto(-197.5,yd)
    turtle.down()
    turtle.seth(0)
    turtle.fd(394)
    yd+=128
    turtle.up()
    turtle.goto(xd,197.5)
    turtle.down()
    turtle.seth(270)
    turtle.fd(394)
    xd+=128
turtle.mainloop()

或者使用 turtle.update 如果你使用 turtle.tracer:

...
turtle.tracer(8,25)
for i in range(2):
    ...
turtle.update()
tracer.mainloop()

这篇关于海龟示踪剂参数示例麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 18:25