[Tkinter-discuss] Callbacks to classes
Bob van der Poel
bob at mellowood.ca
Sat May 21 02:27:40 CEST 2011
New to list ... hope it's not been covered before, and on topic ....
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.
Sorry, this isn't a better (simple) example ... I'm pulling code out a
non-trivial application I've been running for several years. But, most
simply I'd have something like:
Class foo:
... init, and present a options window, etc.
--- set a call back to delete the window when done.
Setting 'cmd' to 'foo' doesn't work anymore. However,
cmd = lambda:foo()
solves the issue.
I'm thinking I've been doing it wrong all along?
Best,
--
**** Listen to my CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bob at mellowood.ca
WWW: http://www.mellowood.ca
More information about the Tkinter-discuss
mailing list