【发布时间】:2018-01-26 15:00:14
【问题描述】:
下面是我的代码(它不处理 penup)。这段代码有什么问题? (对不起我的英语不好。)
import turtle
import time
t = turtle.Turtle()
wn = turtle.Screen()
t.ht()
t.pensize(6)
t.speed(0)
wn.title("Trivia")
class trivia():
def __init__(self):
self.BlueBtn()
def Btn(self):
t.begin_fill()
for p in xrange(2):
t.left(90)
t.fd(170)
t.lt(90)
t.fd(470)
t.end_fill()
def BlueBtn(self): #button a - the blue button
t.penup()
t.setx(-370)
t.pendown()
t.color("blue","aqua") #make the button's color
self.Btn() #make the button
self.RedBtn()
def RedBtn(self): #button b - the red button
t.pu()
t.setx(370)
t.pd()
t.color("darkred","red") #make the button's color
self.Btn()
self.GreenBtn()
def GrennBtn(self): #button c - the green button
t.pu()
t.sety(-400)
t.pd()
t.color("darkgreen","green") #make the button's color
self.Btn(self) #make the button
self.GoldBtn()
def GoldBtn(self): #make button d - the gold button
t.pu()
t.setx(-370)
t.pd()
t.color("gold","khaki") #make the button's color
self.Btn() #make the button
turtle.mainloop() #exit from the turtle screen while pressing on the cross
game = trivia()
【问题讨论】:
-
请编辑问题以使代码部分更易于阅读。使用 Ctrl+K 正确缩进所选代码段
-
寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现它所需的最短代码。另请阅读How to create a Minimal, Complete, and Verifiable example.
标签: python-2.7 turtle-graphics