[Tkinter-discuss] Callbacks to classes
Bob van der Poel
bob at mellowood.ca
Sun May 22 02:22:22 CEST 2011
> Anyway, I've got a number of programs which suddenly stopped working.
> I think due to a change from python 2.6 to 2.7.
> I was setting up a menu call back to a Class with code like:
> Button(bf, text=txt, height=1, command=cmd).grid(column=c, row=0, pady=5)
> when 'cmd' was a simple class name. Doesn't work anymore :)
> However, if I change cmd to a lambda it's find.
I got some help over in comp.python on this. Apparently there was a
change between 2.6 and 2.7. There are 3 easy solutions:
1. Use a function :)
2. Use lambda.
3. Use a new style class, ie:
I've tried all three and they all work. I'm not sure what the best method is.
Best to all.
**** Listen to my CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bob at mellowood.ca
More information about the Tkinter-discuss