
On Fri, Oct 19, 2012 at 8:33 PM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote: ... snip ...
That's another thing that worries me. With a ready-based event loop, this is fairly straightforward. If you can get hold of the file descriptor or handle that the GUI is ultimately reading its input from, all you need to do is add it as an event source to your main loop, and when it's ready, tell the GUI event loop to run itself once.
For most windowing systems, this isn't true. You need to call some function to check if you have events pending. For X11, this is "XPending". For Win32, this is "GetQueueStatus". But overall, the thing is that most GUI libraries have their own event loops. In GTK+, this is done with a "GSource", which can have support for custom sources (which is how the calls to the above APIs are made). What Twisted does is this case is swap out their own select loop with another implementation built around GLib's GMainLoop, which uses whatever internally. I'd highly recommend taking Twisted's approach of having swappable event loops. The question then becomes how you swap out the main loop: Twisted does this with a global reactor which you "install", which the community has found rather ugly, but there isn't really a better solution they've come up with. They've had a few proposals over the years to add better functionality, so I'd like to hear their experience on this.
-- Greg
_______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas
-- Jasper