'Tkinter callback() "TypeError: callback() takes 1 positional argument but 4 were given"
When I type into the entrybox, while i expect the console to print what i've typed the following error is raised:
Traceback (most recent call last):
File "/usr/lib/python3.9/tkinter/__init__.py", line 1892, in __call__
return self.func(*args)
TypeError: callback() takes 1 positional argument but 4 were given
class Editor:
def __init__(self,master):
self.master = master
self.edit_frame = tk.Frame(self.master)
self.elem_frame = tk.Frame(self.master)
self.naz = Nazioni()
paesi = [*self.naz.iso3]
print(paesi)
self.comb_paese = ttk.Combobox(self.edit_frame, value = paesi)
self.comb_paese.current(1)
self.kwordvar= tk.StringVar()
entry_keyword = tk.Entry(self.edit_frame, textvariable=self.kwordvar)
self.kwordvar.trace_add("write",self.callback)
writer = tk.Text(self.edit_frame)
writer.grid(row=0,column=0)
entry_keyword.grid(row=1, column=1)
self.comb_paese.grid(row=1, column = 0)
self.elem_frame.grid(row=0, column = 1)
self.edit_frame.grid(row=0,column=0)
def callback(self):
print(self.kwordvar)
The Editor class is being called with self.newWindow= tk.Toplevel(self.master) as argument, don't know if it has anything to do here but while searching for a solution I've read something about it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
