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

Michiel Jan Laurens de Hoon mdehoon at c2b2.columbia.edu
Mon Nov 14 17:07:45 CET 2005

skip at pobox.com wrote:

>    Ronald> ... except when the GUI you're using doesn't expose (or even
>    Ronald> use) a file descriptor that you can use with select. Not all the
>    Ronald> world is Linux.
>Can you be more specific?  Are you referring to Windows?  I'm not suggesting
>you'd be able to use the same exact implementation on Unix and non-Unix
>platforms.  You might well have to do different things across different
>platforms.  Hopefully it would look the same to the programmer though, both
>across platforms and across toolkits.  I can't imagine any of the X-based
>widget toolkits on Unix systems would use anything other than select() on a
>socket at the bottom.
As far as I know, that is correct (except that some systems use poll 
instead of select). For our extension module, we use select or poll to 
wait for events on Unix (using X). I have not run into problems with 
this on the Unix systems I have used, nor have I received complaints 
from users that this didn't work.

On Windows, the situation is even easier. MsgWaitForMultipleObjects can 
wait for events on all windows created by the thread as well as stdin 
(the same function is used in Tcl's event loop). In contrast to Unix' 
select, we don't need to tell MsgWaitForMultipleObjects which callback 
function is associated with each window.


Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1150 St Nicholas Avenue
New York, NY 10032

More information about the Python-Dev mailing list