How to pass a python event variable into another function? How to pass a python event variable into another function? tkinter tkinter

How to pass a python event variable into another function?


You do not need to attach a command to a button via the bind method; instead, you can use the command key word argument.

In order to pass the item_type argument, you need to iterate over the various arguments corresponding to each button created, and enclose them in the function call as the button is created..

Maybe something like this:

...list_of_items = [item0, item1, item2, ...]item_buttons = []   # keep a reference on each buttonfor y, item in enumerate(list_of_items):    btn = tk.Button(self.itemFrame, command=lambda item=item: self.addtoCart(item), ...)    item_buttons.append(btn)    btn.grid(column=ccount, row=rcount)...