Tkinter: Do you really need a "root"?

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Tue Jun 10 05:16:42 CEST 2003


> In article <c281f461.0306071450.553776ea at posting.google.com>,
>  bobsmith327 at hotmail.com (Bob Smith) wrote:
>>from Tkinter import *
> 
>>root = Tk()
>>app = Frame(root)
>>root.mainloop()
>>
>>But do I really need root?...

Yes. This is an annoying quirk of Tk. If you don't
explicitly create a root window, Tkinter will create
one for you, but one must exist.

You can hide it if you want, though, by doing
root.withdraw().

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list