Exiting Tkinter when using IDLE
Jason Harper
JasonHarper at pobox.com
Sun Mar 14 19:15:00 EST 2004
Ok, this hasn't been tested very well, but it seems to make
IDLE+subprocess work as I'd want it to with Tkinter applications. Just
replace Lib/idlelib/run.py with this file:
http://home.earthlink.net/~jasonrandharper/run.py
You can even do interactive experimentation with Tkinter now. Try this:
>>> from Tkinter import *
>>> root = Tk()
>>> mainloop()
At this point, IDLE's shell window would normally cease to accept input.
Now, you immediately get a prompt back, although internally it's
working rather differently than a normal prompt. Meanwhile, the Tk
window is fully movable, resizable, and closable.
>>> Button(root, text="spam!").pack()
The button immediately appears and is clickable (of course, it doesn't
do much).
>>> Button(root, text="die!", command=root.destroy).pack()
If you use this button, or close the window, the mainloop will exit.
You'll need to create a new root window, and start a new mainloop() if
you want to do anything further with Tk.
Jason Harper
More information about the Python-list
mailing list