I want to generate some buttons dynamically in tkinter, and that each button when it's pushed executes a command which passes and identifier to the function of which button was pushed, for example:
command = function(ButtonId)
and I am generating the buttons like this
for button in range(nbuttons):
buttons.append(tk.Button(master = ButtomFrame, text = 'text', command = lambda : function(button)))
The problem is that as I am defining a lambda when the value of button is updated the value passed to the function is too. I've been trying to find a way to make this work where I can program them in bulk and pass an independent number as their id, but up to now I just have been able to do so if I program each button one by one manually.