I iteratively generate a grid of entry boxes, which are identified by 'ixj' where i and j are the indexes of the box. I would like to attatch traces on their StringVars so that I only operate on one row of this grid at a time.
I currently use:
tk_variable.trace("w", function)
This is then bound to an entry box via it's constructor.
Then 'function' just iterates through every entry box. Is there some way I can pass 'i' to that function, so that when each box is edited, it calls the function, passes its row, and the function then operates on all entry boxes in that row.
Something like:
tk_variable.trace("w", function(i))
However, I know that this syntax actually calls the function, rather than returning an index to it.
I have tried lambda functions:
tk_variable.trace("w", lambda i: function(i))
but I get errors such as:
Exception in Tkinter callback
Traceback (most recent call last):
File "[...]\anaconda3\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
TypeError: <lambda>() takes 1 positional argument but 3 were given
My function is defined:
def function(*args):
Expected results: I can print args, and see the row affected. Any tips?