My code:
import tkinter
master = tkinter.Tk()
master.title(\"test1\")
master.geometry(\"300x300\")
masterFrame = tkinter.Frame(master)
masterFrame.pack(fill=t
When you bind a function fct
to a key (or any other kind of event), the function is called with one argument like that fct(event)
, event
having various attributes depending on the kind of event (mouse position, ...). Your problem is that the function you call drawCheckbox
does not take any argument, so every time you press Enter, it raises an error
TypeError: drawCheckbox() takes 0 positional arguments but 1 was given
To correct it you can either define your function with a default argument,
def drawCheckbox(event=None):
...
or you can use a lambda function to do the binding
master.bind('<Return>', lambda event: drawCheckbox())