Re: quit button

2009-10-26 Thread Gabriel Genellina
En Sat, 24 Oct 2009 23:59:06 -0300, linda.s samrobertsm...@gmail.com  
escribió:



When I click quit button, why the following code has problem?

[...]

if __name__ == '__main__':
root = Tk()
gridbox(Toplevel())
packbox(Toplevel())
Button(root, text='Quit', command=root.quit).pack()
mainloop()


If you run the code from inside IDLE, you'll have to add this line at the  
end:


root.destroy()

as explained here:

http://www.effbot.org/tkinterbook/tkinter-hello-again.htm

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: quit button

2009-10-25 Thread John Posner

linda.s wrote:


When I click quit button, why the following code has problem?

from Tkinter import *
colors = ['red', 'green', 'yellow', 'orange', 'blue', 'navy']

def gridbox(parent):
r = 0
for c in colors:
l = Label(parent, text=c, relief=RIDGE,  width=25)
e = Entry(parent, bg=c,   relief=SUNKEN, width=50)
l.grid(row=r, column=0)
e.grid(row=r, column=1)
r = r+1

def packbox(parent):
for c in colors:
f = Frame(parent)
l = Label(f, text=c, relief=RIDGE,  width=25)
e = Entry(f, bg=c,   relief=SUNKEN, width=50)
f.pack(side=TOP)
l.pack(side=LEFT)
e.pack(side=RIGHT)

if __name__ == '__main__':
root = Tk()
gridbox(Toplevel())
packbox(Toplevel())
Button(root, text='Quit', command=root.quit).pack()
mainloop()
  
Please describe the problem in more detail. Including the exact error 
message, if any, would be very helpful. When I ran this code on Python 
2.6.3rc1 / Windows XP, clicking Quit closed all three windows and 
ended the program. (BTW, nice use of both LEFT and RIGHT packing!)


-John

--
http://mail.python.org/mailman/listinfo/python-list


Re: quit button

2009-10-25 Thread Grant Edwards
On 2009-10-25, linda.s samrobertsm...@gmail.com wrote:

 When I click quit button, why the following code has problem?

It works fine for me (running Gentoo Linux on IA32).

-- 
Grant

-- 
http://mail.python.org/mailman/listinfo/python-list