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

Ronald Oussoren ronaldoussoren at mac.com
Mon Nov 14 07:39:28 CET 2005

On 14-nov-2005, at 2:20, Michiel Jan Laurens de Hoon wrote:

> skip at pobox.com wrote:
>> If I have a Gtk app I have to feed other (socket, callback) pairs  
>> to it.  It
>> takes care of adding it to the select() call.  Python could  
>> dictate that the
>> way to play ball is for other packages (Tkinter, PyGtk, wxPython,  
>> etc) to
>> feed Python the (socket, callback) pair.  Then you have a uniform  
>> way to
>> control event-driven applications.  Today, a package like  
>> Michiel's has no
>> idea what sort of event loop it will encounter.  If Python  
>> provided the
>> event loop API it would be the same no matter what widget set  
>> happened to be
>> used.
> This is essentially how Tcl does it (and which, btw, is currently  
> being
> used in Tkinter):
> Tcl has the functions *Tcl_CreateFileHandler/**Tcl_DeleteFileHandler*,
> which allow a user to add a file descriptor to the list of file
> descriptors to select() on, and to specify a callback function to the
> function to be called when the file descriptor is signaled. A similar
> API in Python would give users a clean way to hook into the event  
> loop,
> independent of which other packages are hooked into the event loop.

... except when the GUI you're using doesn't expose (or even use) a file
descriptor that you can use with select. Not all the world is Linux.

BTW. I find using the term 'event loop' for the interactive mode very


More information about the Python-Dev mailing list