Tkinter programming problem

klappnase klappnase at web.de
Thu Aug 7 10:11:17 EDT 2003


"Mark Daley" <mark at diversiform.com> wrote in message news:<mailman.1060190417.25846.python-list at python.org>...
> I have problems with sys.exit() when I'm running under IDLE, since it seems
> to cause ALL mainloops to exit, killing IDLE.  I can't really give a whole
> lot of detail on this, since I tend to use the command line to launch my
> GUIs, anyway.
> 
sys.exit()will stop (exit) the python interpreter. If you are running
your program from within IDLE it will exit IDLE, too, because IDLE
runs in the interpreter as well.
If you run your program from the command line sys.exit() will exit the
interpreter and stop the program, of course any instructions in the
code after sys.exit() won't be executed.
I think normally that is exactly what I want in a gui program - stop
everything if the main window is closed.
widget.destroy() will destroy "widget" and if "widget" is the main
window of your application it will be destroyed - and all it's
children with it.
That's the way it should work if you are running from within the
interpreter:
your application is stopped but the interpreter won't be affected by
this.
widget.quit() exits the mainloop and therefore destroys the main
window but it will not exit the interpreter, so there may be other
processes in your code still be executed after the main window is
closed. If all processes in the interpreter are finished the
interpreter will exit anyway, so this will work as well as sys.exit().
However, if you run your program from the interpreter this will not
work, because you do not call a mainloop there.

Cheers

Michael




More information about the Python-list mailing list