[Tutor] What does parent=0 mean?

Kent Johnson kent_johnson at skillsoft.com
Tue Aug 24 22:44:07 CEST 2004


At 01:16 PM 8/24/2004 -0700, Chad Crabtree wrote:
>I believe that the only tkinter widget that can have no parent is the
>frame.    When a frame has no parent then it is the main frame that
>hold
>*everything* else.

That's not quite right. You can omit the parent on any widget. If it is 
omitted, the parent will be the root widget (the one you create with 
something like "root=Tk()"). For example this program works. I don't claim 
that it is good style but it does work.

from Tkinter import *

root = Tk()
Label(text="This is a test").pack()
Button(text="OK").pack()
root.mainloop()

Kent



More information about the Tutor mailing list