[Python-Dev] Event loops, PyOS_InputHook, and Tkinter

"Martin v. Löwis" martin at v.loewis.de
Tue Nov 8 21:37:41 CET 2005


Michiel Jan Laurens de Hoon wrote:
> 1) Did I miss something? Is there some way to get an event loop with 
> Tkinter?

Yes, and yes. You are missing multi-threading, which is the widely used
approach to doing things simultaneously in a single process. In one
thread, user interaction can occur; in another, computation. If you need
non-blocking interaction between the threads, use queues, or other
global variables. If you have other event sources, deal with them
in separate threads.

Yes, it is possible to get event loops with Tkinter. Atleast on Unix,
you can install a file handler into the Tk event loop (through
createfilehandler), which gives you callbacks whenever there is some
activity on the files.

Furthermore, it is possible to turn the event loop around, by doing
dooneevent explicitly.

In principle, it would also be possible to expose Tcl events and
notifications in Tkinter (i.e. the
Tcl_CreateEventSource/Tcl_WaitForEvent family of APIs). If you think
this would help in your case, then contributions are welcome.

> 2) Will Tkinter always be the standard toolkit for Python, or are there 
> plans to replace it at some point?

Python does not evolve along a grand master plan. Instead, individual
contributors propose specific modifications, e.g. through PEPs.

I personally have no plan to replace Tkinter.

Regards,
Martin


More information about the Python-Dev mailing list