【发布时间】:2016-11-01 08:55:14
【问题描述】:
每次按键盘上的x 时,我都会尝试将窗口中的乌龟尺寸加倍。我尝试使用.turtlesize(2,2,2),但这是不对的。每次按下键时我都需要加倍,因此如果海龟大小为(1,1,1),则每次按下x 时,它将变为(2,2,2),然后变为(4,4,4),依此类推。
这是我目前所拥有的:
import turtle
turtle.setup(500,500)
wn = turtle.Screen()
wn.title("Commands")
wn.bgcolor("black")
tess = turtle.Turtle()
tess.shape("triangle")
tess.color("red")
tess.left(90)
def increaseSize():
size = tess.turtlesize()
increase = tuple([2 * num for num in size])
tess.turtlesize(increase) #this is where the error occurs
wn.onkey(increaseSize, "x")
wn.listen()
【问题讨论】:
-
你得到什么具体的错误信息?
标签: python resize turtle-graphics