So, the problem is is that the "onclick" function is not working. It is instead just printing the test code (print(‘working’)) when the code is started. Please help!
SubmitButton = turtle.Turtle()
SubmitButton.penup()
SubmitButton.goto(0,-300)
SubmitButton.shape('square')
SubmitButton.shapesize(2)
SubmitButton.fillcolor('red')
SubmitButton.penup()
SubmitButton.goto
SubmitButton.onclick(print("working"))
There is the snippet of the code, lemme know if you need anymore.
>Solution :
onclick needs to be passed a function, which it will call. The function needs to have two arguments. (See the Documentation, which you should always look up before posting here). You’re passing it the returned value of a print(), which is None. You could use a lambda, which creates a function that will call print() when that function is called:
SubmitButton.onclick(lambda x, y: print("working"))
Or you could define a function and pass that in:
def onclick_function(x, y):
print("working")
SubmitButton.onclick(onclick_function)
Notice though how I’m passing in onclick_function but not calling that function.