I raise this question because I just saw this question What are the limitations of callback functions associated with Tkinter traces?.
And I use lambda
to add another arguemnt.
Here is the code:
from tkinter import *
def callbackfunc(*args, **kwargs):
print(args,kwargs)
class App(object):
def __init__(self, master):
frame = Frame(master)
frame.pack()
optionvalue = IntVar(master)
optionvalue.set(2)
optionvalue.trace("w",lambda a,b,c,x='test':callbackfunc(x))
self.optionmenu = OptionMenu(master, optionvalue, 1, 2, 3, 4)
self.optionmenu.pack()
root = Tk()
app = App(root)
root.mainloop()
my output: ('test',) {}
What I want to know is:
Why aren't the other 3 arguments outputted if I use lambda?