I have been programming python for 4 years, (and programming for 30 years) and have made your mistake on more than one occasion.
Mick On Tue, Nov 3, 2009 at 8:20 PM, Bogus Zaba <bo...@bogzab.plus.com> wrote: > I was right - a rookie mistake. Sorry to take up your time... > > Bogus > > Michael O'Donnell wrote: >> >> HI Bogzab, >> >> >>> >>> def wait_a_bit(): >>> topwin.iconify >>> print "Pressed No" >>> >> >> change the second line for: >> topwin.iconify() >> >> You need to end a method call with () to indicate it is >> an invocation. Otherwise, the statement just returns >> a pointer to the method. >> >> Mick >> >> >> On Mon, Nov 2, 2009 at 10:48 PM, bogzab <bo...@bogzab.plus.com> wrote: >> >>> >>> I think I am making a rookie error with this somewhere but cannot figure >>> out >>> where. >>> >>> If I create a button with these lines of code : >>> >>> topwin = Tk() >>> ... >>> frame = Frame(topwin) >>> ... >>> butt2 = Button(frame, text="Not yet", command=topwin.iconfiy) >>> >>> When the program runs, the button acts as expected and the window is >>> iconified. >>> >>> If however the line which creates the button is : >>> >>> butt2 = Button(frame, text="Not yet", command=wait_a_bit) >>> >>> where wait_a_bit is a function I define as follows : >>> >>> def wait_a_bit(): >>> topwin.iconify >>> print "Pressed No" >>> >>> then the print statement in this function works, but the topwin.iconify >>> statement >>> does not. >>> >>> I have tried declaring topwin to be global but this made no difference. >>> >>> Can anybody point me to where my error lies in the second approach ? I >>> want >>> to >>> do it as a function because there are other bits of code as well as the >>> iconify >>> that I need to incorporate. >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/How-to-make-Button-Command-work-as-a-called-function---tp26157859p26157859.html >>> Sent from the Python - tkinter-discuss mailing list archive at >>> Nabble.com. >>> >>> _______________________________________________ >>> Tkinter-discuss mailing list >>> Tkinter-discuss@python.org >>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>> >>> >> >> > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss@python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss