[Python-Dev] Event loops, PyOS_InputHook, and Tkinter
ronaldoussoren at mac.com
Mon Nov 14 19:19:14 CET 2005
On 14-nov-2005, at 16:00, skip at pobox.com wrote:
> Ronald> ... except when the GUI you're using doesn't expose (or
> 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 was thinking of MacOS X. It does have a eventloop, but doesn't
file descriptor to the user and might not even use one.
Adding Python's input to the runloop of the GUI might be easier (e.g.
the stdin filedescriptor to the GUI-toolkit-du-jour and process
when that runloop tells you that data is present). We have an example
in the PyObjC source tree.
I'd say either choice won't be very good. The problem is that you must
interleave the execution of Python code with running the eventloop to
nice behaviour, which suggests threading to me. If you don't interleave
you can easily block the GUI while Python code is executing.
> I'm not suggesting
> you'd be able to use the same exact implementation on Unix and non-
> platforms. You might well have to do different things across
> platforms. Hopefully it would look the same to the programmer
> though, both
> across platforms and across toolkits.
Twisted anyone? ;-) ;-)
> 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.
I'd be very surprised if an X-based toolkit didn't use a select-loop
More information about the Python-Dev