problem with tk and pass by refference (I think :)
Diez B. Roggisch
deetsNOSPAM at web.de
Fri Feb 11 13:55:55 EST 2005
Hi,
button = Button(self.songWin, text=verse, command=(lambda num=verseNum:
self.showVerse(num)) )
should do the trick. The reason is basically that your version kept a
reference to verseNum - and when executed, the value verseNum points to is
the lasts one stored.
Rebinding the argument to a parameter in the lambda will keep the right
value for each iteration.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list