Tkinter: IDLE can't get out of mainloop

Frederic Rentsch anthra.norell at bluewin.ch
Sat Mar 31 03:42:59 EDT 2012


Hi all,

Is is a bad idea to develop Tkinter applications in IDLE? I understand
that IDLE is itself a Tkinter application, supposedly in a mainloop and
mainloops apparently don't nest.

I tried to install a root-destroy-protocol:

def destroy_root ():
	print 'Destroying root'
	root.destroy ()

root.protocol ("WM_DELETE_WINDOW", destroy_root)

I see the tracing message 'Destroying root', but stay stuck unable to
get the IDLE prompt back. Ctr-C doesn't work. The only way out I know is
killing IDLE. When I do, a warning says that a program is still running.
That must be IDLE's own WM_DELETE_WINDOW protocol. Is there a way to get
the prompt back without killing IDLE? Is there a way to nest a
mainloop? 
   Up to now I have been able to get by without a mainloop. I suppose
this is because I have only been doing layouts. Starting now to do
events I observe what in the absence of a mainloop looks like
synchronization problems with bindings responding to other events than
their own.
   If I run from a terminal things seem to work out. Is it standard
development practice to run code from a terminals ($ python program.py)?
What's the 'program.pyc' for if the source is compiled every time?
   I use Python 2.6 on Ubuntu 10.04 LTS.
 
Thankful for any suggestion

Frederic





More information about the Python-list mailing list