[IPython-dev] Uniform way of integrating event loops among different IDE's
Fernando Perez
fperez.net at gmail.com
Mon Aug 30 03:18:55 EDT 2010
Hi Almar,
returning to your original thread, which got a little sidetracked by
our licensing discussion... :)
7
On Tue, Aug 24, 2010 at 8:06 AM, Almar Klein <almar.klein at gmail.com> wrote:
> I'm developing an IDE for Python (http://code.google.com/p/iep/) that is
> capable of integrating the event loop of several GUI toolkits. On a side
> note, I used much code of IPython as inspiration on how to do that, so
> thanks for that.
>
> I saw in the IPython documentation that IPython users can detect whether
> IPython hijacked the event loop as follows (for wx):
>
> try:
> from IPython import appstart_wx
> appstart_wx(app)
> except ImportError:
> app.MainLoop()
>
> A very nifty feature indeed. However, building further on this, wouldn't it
> be nice if people could perform this trick regardless of in which IDE or
> shell the code is running? Therefore I propose to insert an object in the
> GUI's module to indicate that the GUI event loop does not need to be
> entered. I currently use for my IDE:
>
> import wx
> if not hasattr(wx, '_integratedEventLoop'):
> app = wx.PySimpleApp()
> app.MainLoop()
>
> Currently, _integratedEventLoop is a string with the value 'IEP', indicating
> who hijacked the main loop. I'm not sure what IPythons appstart_* function
> does, but the inserted object might just as well be a function that needs to
> be called (using the app instance as an argument, but how to call it for
> fltk or gtk then?).
>
> I'm interested to know what you think of this idea.
Well, Brian just implemented more or less this very same thing:
http://github.com/ipython/ipython/blob/newkernel/IPython/lib/guisupport.py
We decided to call the attribute '_in_event_loop' instead, partly for
PEP-8 reasons but especially because Enthought was already using that
name. Absent a good reason to deviate from their chosen name, which
is already in a very large codebase, we figured we'd use that.
So let's hope we can get all GUI projects to agree on this approach,
and it should become possible with only minimal work on the part of
authors to coexist well with the event loops of various toolkits and
interactive apps like IPython or IEP.
Regards,
More information about the IPython-dev
mailing list