save value of a tkinter button

0

Basically, I generate buttons within a for that runs through a dictionary, as the dictionary size varies with each search.

for a in resultados:
    id = a['id'] 
    btnDetails = Button(self.label1, text=a['nome'], command=lambda : self.motra_detalhes(id))
    btnDetails.pack()

When executing this section, the program generates all the buttons, but the variable id ends up with the last value of the loop.

Any solution for the id variable to receive the value corresponding to id of the button that the user clicks?

    
asked by anonymous 31.05.2018 / 04:01

0 answers