Strange terminal behavior after quitting Tkinter application

Chris ceball at gmail.com
Sun May 6 04:39:54 EDT 2007


On May 5, 2:21 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On 4 May 2007 19:38:39 -0700, Chris <ceb... at gmail.com> declaimed the
> following in comp.lang.python:
>
>
>
> > 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 guess I'm confused by "while still being able to use the
> interactive interpreter"... Unless your "Application()" starts a
> separate thread to handle the GUI interaction, the interpreter itself
> will not interact until it exits and returns control to the interpreter.

Maybe the Python interpreter is setup specially for Tkinter, I don't
know - but one can definitely have a Tkinter GUI working and use the
interpreter too (by not calling mainloop()). The Application example
in my first post works (except for the messed-up terminal) and the
interpreter is not blocked.

Perhaps it becomes necessary to call update or update_idletasks()
after some operations for the GUI to update itself - I'm not entirely
sure (I haven't been able to find any documentation) - but apart from
that there are no problems I know about.


>
> > I need to find out what cleanup is performed after mainloop() exists,
> > I guess.
>
>         <G> If you are calling it, it "exists"... Whether it "exits" is
> another matter <G>
>
>
>
> > 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.
>
>         I'll admit to being surprised at seeing a claim that a tkinter
> application, started within an interactive session, without a mainloop,
> even runs... I could see it maybe happening from Idle, since Idle is
> running a tkinter mainloop, so the application bindings may have just
> become "added widgets" to the Idle loop (but of course, a second
> mainloop would conflict heavily).

You can try by building a working Tkinter GUI interactively from the
standard Python interpreter, and see that the GUI works (i.e.
processes events) at the same time.


>         That link reads as if the IronPython interpreter can be started with
> a wx/gtk mainloop already running as a thread -- so any application code
> might, as with my tkinter/Idle thoughts, be added to the already running
> loop.

I don't know how ipython works, just that it allows a GUI and
interpreter to work together for wxpython (whereas usually you can
only use a GUI and the python interpreter when the GUI is Tkinter).


Chris




More information about the Python-list mailing list