Turtle.onclick problem

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
 
Joined
Feb 14, 2022
Messages
33
Reaction score
2
it is working but in my program there is a code called:
def Button_click():
if Button_x<=x<=Button_x+Buttonlength:
if Button_y<=y<=Button_yButtonWidth:
print("clicked")
and it is not showing the word "clicked" is not appearing on the screen can you help me with this problem too thack you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top