Answer the question
In order to leave comments, you need to log in
Why do buttons stop working?
Good day dear colleagues. I decided to indulge in the "turtle" library and wrote a mini game. In short, I created a function to change the settings of the turtle. But after I open and set the settings for the turtle, the other control buttons stop working. Here is the main program code:
"""
Turtle Game v.0.6
by Klaver.
#Main#
"""
from turtle import *
from time import sleep
import pyautogui
from tcontrols import *
def test():
print("11")
def main():
shape('turtle')
title("Turtle game by Klaver")
text = "Привет, мир!"
pu()
setpos(0, 295)
write(text, move = False, align = "center", font = ("Arial", 20, "normal"))
home()
showturtle()
filling()
speed(10)
sleep(3)
clear()
"""##########################"""
onkeypress(sett, "*")
onkeypress(f, "w")
onkeypress(b, "s")
onkeypress(r, "d")
onkeypress(l, "a")
onkeypress(f, "8")
onkeypress(b, "2")
onkeypress(r, "6")
onkeypress(l, "4")
onkeypress(rf, "9")
onkeypress(lf, "7")
onkeypress(rb, "3")
onkeypress(lb, "1")
onkeypress(drawing, "o")
onkeypress(ndrawing, "p")
onkeypress(cl, "x")
onkeypress(hm, "h")
onkeypress(save, "0")
listen()
main()
from turtle import *
from time import sleep
import pyautogui
def f():
look = heading()
if look > 90 or look < 90:
setheading(90)
else:
fd(10)
def b():
look = heading()
if look > 270 or look < 270:
setheading(270)
else:
fd(10)
def r():
look = heading()
if look > 0 or look < 0:
setheading(0)
else:
fd(10)
def l():
look = heading()
if look > 180 or look < 180:
setheading(180)
else:
fd(10)
def rf():
look = heading()
if look > 45 or look < 45:
setheading(45)
else:
fd(10)
def lf():
look = heading()
if look > 135 or look < 135:
setheading(135)
else:
fd(10)
def rb():
look = heading()
if look > 325 or look < 325:
setheading(325)
else:
fd(10)
def lb():
look = heading()
if look > 215 or look < 215:
setheading(215)
else:
fd(10)
def drawing():
pd()
def ndrawing():
pu()
def cl():
pu()
clear()
home()
def hm():
pu()
home()
def save():
pyautogui.hotkey("esc", "delete")
def sett():
clr = textinput("Настройки", "Выбери цвет: ")
psize = numinput("Настройки", "Установи толщину пера: ")
fillColor = textinput("Настройки", "Выбери цвет заливки: ")
color(clr)
pensize(psize)
fillcolor(fillColor)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question