List Info

Thread: simple script -Tkinter question.




simple script -Tkinter question.
user name
2006-07-04 07:48:44
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.

Hope this helps,

Matthias Kievernagel
mkiever/at/web/dot/de
software development

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discusspython.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
simple script -Tkinter question.
user name
2006-07-04 09:59:10
On Tue, 4 Jul 2006 09:48:44 +0200
mkieverpytlink.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."""
    _default_root.tk.mainloop(n)

(...snip...)

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
        (...snip...)
        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.

Michael
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discusspython.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )