Strange terminal behavior after quitting Tkinter application

Chris ceball at gmail.com
Fri May 4 22:38:39 EDT 2007


On May 5, 1:24 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On 4 May 2007 08:02:13 -0700, Chris <ceb... at gmail.com> declaimed the
> following in comp.lang.python:
>
> > Ah, sorry, I wasn't being precise. I meant the python commandline
> > python interpreter.
>
> > So from aterminalI type (for example):
> > python -i application.py
>
> > This launches the interpreter in myterminal. Then I can start the GUI
> > (by typing "Application()", for example). If I use mainloop(), I can't
> > interact with the interpreter from theterminaluntil I quit the GUI.
> > Without mainloop(), I can continue to enter python commands.
>
>         Which is to be expected... As the name implies, it is a loop. The
> Python interpreter doesn't produce an interactive prompt until it runs
> out of code to execute. Enter the following at an interactive prompt and
> see what happens:
>
> while True: pass
>
> mainloop() is similar, though filled out with event dispatching logic:
>
> while True:
>         #get input event (keyboard, mouse clicks, mouse motion, etc.)
>         #call handler for that type of event
>
>         All common GUI toolkits work this way (The AmigaOS was pretty much
> the only exception, in that it did NOT natively rely upon binding
> callbacks to events and then starting a library loop; one had to code
> the dispatch loop by hand -- but this did mean that one could code a
> subloop within an event handler if needed to restrict the available
> events).

Thanks, but I was just explaining why I don't want to call mainloop().
In my original example, I can type Application() at the interactive
prompt and get a GUI (which seems to work apart from not quitting
properly and leaving a messed-up terminal on some versions of linux)
while still being able to use the interactive interpreter.

I need to find out what cleanup is performed after mainloop() exists,
I guess.


Incidentally, I found the information in the thread
http://thread.gmane.org/gmane.comp.python.scientific.user/4153
quite useful regarding mainloop() and being able to use python
interactively from the prompt while still having a GUI.





More information about the Python-list mailing list