[Tkinter-discuss] How to make Button Command work as a called function ?
bogzab
bogus at bogzab.plus.com
Mon Nov 2 22:45:43 CET 2009
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---tp26157856p26157856.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
More information about the Tkinter-discuss
mailing list