[IPython-dev] GUI support: conflicts between IPython 0.11 and Matplotlib/ETS

Brian Granger ellisonbg.net at gmail.com
Thu Feb 11 15:07:06 EST 2010


Hans,

> From a user's perspective (i.e. not from an MPL/ETS point of view), the
> above
> also rings bells: I am used to running GUI apps from within ipython, where
> (with older IPython versions) I'll get at most an exception from running
> sys.exit(), but my main window pops up and the app is running while I still
> have the interpreter available.  That's an incredibly important use case to
> me.

Yes and we absolutely need to support this usage case.

> Now if the mainloop must not be started with 0.11, how about monkey-patching
> the application classes (i.e. QCoreApplication.exec_) in order to allow
> running unpatched programs when the GUI toolkit integration is active?

Fernando and I spend a full day at Scipy 2009 trying this monkey
patching approach.
Summary: it doesn't work.  Full details: each GUI toolkits has additional ways
of running the event loop (other than just calling "run") for a short
period of time.  If everyone avoided these other calls the monkey
patch approach would work.  But *many* people (including matplotlib
and traits) do need to spin the event loop by hand and call these
functions.  All of our monkeypatch approaches broke these things.

> (In fact, in our own Qt3-based python terminal, we had monkeypatched
> QApplication in order to also ignore the creation of a second app object.)

Yes, this type of monkey patch is not too difficult to handle.  But
*any* GUI app should first call getApp or its equivalent before
creating an App object to make sure a 2nd one is created.  The more
difficult one is to figure out if the event loop is running.  This is
difficult because there are so many different ways of running the
event loop and the "isMainLoopRunning" type functions don't account
for all of these.

Cheers,

Brian

> --
> Ciao, /  /                                                    .o.
>      /--/                                                     ..o
>     /  / ANS                                                  ooo
>



More information about the IPython-dev mailing list