Tkinter and IDE's

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Mon Nov 19 21:15:41 EST 2001


>>>>> "JS" == Jeff Shannon <jeff at ccvcorp.com> writes:

    JS> There are two problems with running Tkinter in most IDE's.
    JS> One is that Tk-based apps share the same event queue, so that
    JS> running a Tk app inside of another Tk app will confuse things.
    JS> The other is that different GUI toolkits almost never play
    JS> well together, so running a Tk app inside of a different GUI
    JS> kit's apps will confuse things.

Actually, I've found that if you dont do a root.mainloop() in your
application when you aren't running it as a standalone application
(i.e. outside of an IDE/Interpreter) things run really well with
Tkinter.  For instance you can simply run the following from a Python
interpreter shell or even from idle:

import Tkinter
r = Tkinter.Tk()
def f(evt=None):
  print "foo"
b = Tkinter.Button(r, text="test", command=f)
b.pack()
# click away on the button.
prinf "hello world!"
"hello world!"

I've used this plenty of times and not with just 'toy apps' like the
one above but with full fledged applications and even with VTK
RenderWindows embedded in it etc.  I've done this under Win32
(Idle/shell) and Linux and it has always worked.

I have not tried this with PythonWin and have heard that this will not
work with it.  However, I do most of my work on Xemacs + an rxvt
running a Python interpreter and that combination with a nice
pythonstartup.py can be extremely productive. :)

prabhu




More information about the Python-list mailing list