Tkinter - Multiple Tk() instances/mainloops in one process?

Gregory Sheaffer sheaffgr at
Wed Mar 25 05:55:33 CET 2009

I've been working on a Python project for several weeks involving a client
for connecting to an AIM distribution server and holding multiple
conversations in separate windows.

Without getting into a lot of detail, the basic main program loop is

       on message recieved
                    if new conversation
                              create a thread for a new window instance
                    if old conversation
                              route to that window for printing

The window instance is a Tkinter GUI class, on a basic level
        *stuff for root*

All the windows involved work fine when tested individually, and when run
the system handles a single conversation and that window fine (And another
after the first has been closed). However, if at any time we attempt to have
multiple windows (Which are in separate threads each with their own Tk()
call) the windows beyond the first fail to appear and tkinter seems to get
stuck in an infinite loop somewhere in the new mainloop() call.

So, basically, is this a problem inherent in using Tkinter? And if so, are
there any workarounds besides tying the windows to a root Tk() in the main
program (Which isn't really an option the way the system is currently
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list