I created button dynamically and i want to give them a command to change their picture and change position. Now is the problem that i dont manage to pass the button himself in command
I exchanged the pictures in the code below with text but the problem is still the same.
It doesn't work with lambda or i haven't used it right.
from tkinter import *
karten = {'Stapel': [['D','A','BDA','D'],['D','2','BD2','D']]}
def p(button):
button.config(text='HI')
RS = 'RS'
DA = 'DA'
D2 = 'D2'
root = Tk()
for i in karten:
for j in karten[i]:
vars()[j[2]] = Button(root,text=vars()[j[0]+j[1]],command=lambda: p(vars()[j[2]]))
vars()[j[2]].pack()
root.mainloop()
i expected that the button changes the text but it only produced an error.