Tkinter: Do you really need a "root"?

Bob Smith bobsmith327 at
Sun Jun 8 00:50:18 CEST 2003

Hi.  I'm just starting to learn to use the Tkinter module for creating
GUIs.  I'm using a tutorial that gives a basic starting program of:

from Tkinter import *
root = Tk()
app = Frame(root)

But do I really need root?  It seems like the program could simply be:

from Tkinter import *
app = Frame()

This second program works just as well as the first and seems more
intuitive to me.  I'm creating an application that is a Frame and I
start the application by invoking the application's mainloop() method.

The first example seems more obtuse.  root seems unnecessary and
invoking root's mainloop() instead of app's seems odd to me too (if I
want to start app, I should invoke a method of app).

So, what's wrong with the second version?  Will I run into problems
later when I add more widgets and get into more complex GUIs?


More information about the Python-list mailing list