Python Turtle帮助文档梳理
Python Turtle帮助文档真的很多,几十屏拉不到头。其中很多部分是重复的。近期进行了梳理,我将其分为全局控制、画布设置、画笔设置、画笔操作、互动等五个部分。
说明:
1)Python Turtle查询办法 help(turtle)
2)查询某函数xx的方法 help(turtle.xx),例如help(turtle.home)
一、全局控制
clear(self)
reset(self)
home(self)
undo(self)
write(self, arg, move=False, align='left',
font=('Arial', 8, 'normal'))
speed(self, speed=None)
bye()
setundobuffer(self, size)
degrees(self, fullcircle=360.0)
distance(self, x, y=None)
towards(self, x, y=None)
pos(self)
radians(self)
xcor(self)
ycor(self)
listen(self,
xdummy=None, ydummy=None)
tracer(self,
n=None, delay=None)
turtles(self)
update(self)
mainloop(self)
exitonclick()
resizemode(rmode=None)
done = mainloop()
二、画布设置
setup(width=0.5, height=0.75, startx=None,
starty=None)
screensize(canvwidth=None, canvheight=None,
bg=None)
window_height(self)
window_width(self)
bgpic(self, picname=None)
三、画笔设置
pensize(self, width=None)= width()
pencolor(*args)
turtlesize = shapesize(self,
stretch_wid=None, stretch_len=None, outline=None)
settiltangle(self, angle)
shape(self, name=None)
hideturtle(self)
showturtle(self)
shapetransform(self, t11=None, t12=None,
t21=None, t22=None)
shearfactor(self, shear=None)
tiltangle(angle)=
tilt (angle)= settiltangle(angle)
color(self, *args)
fillcolor(self, *args)
pen(self, pen=None, **pendict)
resizemode(self, rmode=None)
register_shape(self, name, shape=None)= addshape(name,
shape=None)
四、画笔操作相关函数
pendown(self)
penup(self)
right (angle)
left (angle)
forward(self, distance)
back(self, distance)
goto(self, x, y=None)
circle(self, radius, extent=None,
steps=None)
dot(self, size=None, *color)
begin_fill(self)
end_fill(self)
begin_poly(self)
end_poly(self)
get_poly(self)
get_shapepoly(self)
clone(self)
stamp(self)
clearstamp(self, stampid)
clearstamps(self, n=None)
heading(self)
setheading(self, to_angle)
setpos = goto(self, x, y=None)
setx(self, x)
sety(self, y)
get_shapepoly(self)
filling(self)
getpen = getturtle(self)
getscreen(self)
isdown(self)
isvisible(self)
五、互动相关函数
onclick(self, fun, btn=1, add=None)
ondrag(self, fun, btn=1, add=None)
onrelease(self, fun, btn=1, add=None)
onkey(self, fun, key)
onkeypress(self, fun, key=None)
onkeyrelease = onkey(self, fun, key)
ontimer(self, fun, t=0)
numinput(self, title, prompt, default=None,
minval=None, maxval=None)
textinput(self, title, prompt)