Tkinter causes hang

Stephen Ferg ferg_s at bls.gov
Mon Apr 16 12:59:47 EDT 2001


Problem Summary:

I am running a Python program in a console window under Windows 95/98.  The
program uses Tkinter.  When the program finishes, it hangs -- that is, I
don't get the command-line prompt back again.

Detailed Description:
-------------------------------------

I'm using Python 2.0 and Tkinter under Windows 95/98.

My programming task is to build a program whose user interface is mainly a
GUI (hence Tkinter), but which runs utilities that write their output to
stdout.  The program must display the utilities' output in a console-type
window.

To provide this kind of functionality, I am opening a "DOS box" (i.e. a
console window) in Windows, and starting my Python program in the console
window from the command-line prompt with the command:

      python test1.py

and then displaying GUI-type messageboxes using Tkinter.  But adding code to
my program to display a simple messagebox causes the following problem --
when my program finishes, I don't get the command-line prompt back in the
console window. The only way I can close the console window is to "crash"
the console window using control+alt+delete and the Task Manager.

For instance, after the messagebox is closed, this program...

   from Tkinter import *
   root = Tk()
   widget = Label(root, text="This is a test")
   widget.pack()
   widget.mainloop()
   print "done!"

...prints "done!" and then the console just sits there -- the command prompt
doesn't come back.

Any suggestions as to what the problem is, and how to get around it?

Thanks in advance for any help.

-- Steve Ferg (ferg_s at bls.gov)






More information about the Python-list mailing list