This is the method I have inside a Tkinter frame which I am trying to call using key_press() but get the error.
ERROR MESSAGE
I am probably making a rookie error here but cannot see the wood from the trees so need some help please.
The function runs ok in IDLE without the call.
CODE SNIPPET
ERROR MESSAGE
Error:Traceback (most recent call last):
File "/home/eric/Python_Projects/Window1.py", line 53, in <module>
key_press()
TypeError: key_press() takes exactly 1 argument (0 given)
I am struggling to find out which argument to pass.I am probably making a rookie error here but cannot see the wood from the trees so need some help please.
The function runs ok in IDLE without the call.
CODE SNIPPET
main_window =Tk() def key_press(event): if event.keysym == "1": #if key pressed = 1 then go to next frame print ("Next") elif event.keysym == "9": # if key pressed = 9 then quit application. print ("Quit") main_window.bind("<Keys>", key_press) key_press() #call key_press function main_window.mainloop()
buran write Sep-11-2023, 12:27 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.