- Joined
- Feb 14, 2022
- Messages
- 33
- Reaction score
- 2
my name is kiaan and a am nine years old I am coding I python i am making my first app i have done graphics now I am doing buttons I have done the graphics for the buttons and it worked but the function is not working so to make a button clickable you need to write "turtle.onclick()" but when I write it ,it says there is a word I have not added "fun" so I write
"turtle.onclick(fun)" and it says fun is not recognized to make it less confusing I will show the code:
import turtle
t = turtle.Turtle()
t.hideturtle()
for i in range(2):
t.forward(80)
t.left(90)
t.forward(30)
t.left(90)
t.penup()
t.goto(7, 6)
t.write("Start/Run", font=("Arial",12,"normal"))
def Button_click():
if Button_x<=x<=Button_x+Buttonlength:
if Button_y<=y<=Button_yButtonWidth:
print("clicked")
t.onclick(button_click)
t.mainloop()
can someone plz help me with this problem
"turtle.onclick(fun)" and it says fun is not recognized to make it less confusing I will show the code:
import turtle
t = turtle.Turtle()
t.hideturtle()
for i in range(2):
t.forward(80)
t.left(90)
t.forward(30)
t.left(90)
t.penup()
t.goto(7, 6)
t.write("Start/Run", font=("Arial",12,"normal"))
def Button_click():
if Button_x<=x<=Button_x+Buttonlength:
if Button_y<=y<=Button_yButtonWidth:
print("clicked")
t.onclick(button_click)
t.mainloop()
can someone plz help me with this problem