[Tkinter-discuss] simple script -Tkinter question.

Michael Lange klappnase at web.de
Tue Jul 4 11:59:10 CEST 2006

On Tue, 4 Jul 2006 09:48:44 +0200
mkieverpy at tlink.de wrote:

> Hi jkuo!
> >Hi everyone,
> >Here is my simple Tkinter script:
> >## start of entry.py
> >from Tkinter import *
> >root=Tk()
> >e1=Entry(root, width=16)
> >e1.pack()
> >e2=Entry(root, width=16)
> >e2.pack()
> >mainloop()
> >## end
> You should call 'root.mainloop()'!
> Just mainloop() is the mainloop of Tcl, not Tk.
> I don't know what the effects of this might be.
> On Linux everything seems to work, nonetheless.

Really? From Tkinter.py it looks to me like it should be equivalent:

def mainloop(n=0):
    """Run the main loop of Tcl."""


class Tk(Misc, Wm):
    """Toplevel widget of Tk which represents mostly the main window
    of an appliation. It has an associated Tcl interpreter."""
    _w = '.'
    def __init__(self, screenName=None, baseName=None, className='Tk'):
        global _default_root
        if _support_default_root and not _default_root:
            _default_root = self

so _default_root is the  Tk() instance. Unfortunately this does not explain what is going wrong in the example.


More information about the Tkinter-discuss mailing list