Tkinter: passing parameters to menu commands (looping througha list)

Michael Fuhr mfuhr at
Fri Jan 7 16:56:54 EST 2005

"Philippe C. Martin" <philippecmartin at> writes:

> l_dec_list = ['ATR','IN']
> for i in l_dec_list:
>   l_dec.add_command(label = i, command= lambda: self.__Dec(i))

Give the lambda an argument with a default:

l_dec.add_command(label=i, command=lambda x=i: self.__Dec(x))

Michael Fuhr

More information about the Python-list mailing list