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

Hans Meine hans_meine at gmx.net
Fri Feb 12 04:42:32 EST 2010


On Thursday 11 February 2010 21:07:06 you wrote:
> > 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. 

That's very interesting, I'd like to know more details.

> Full details: each GUI toolkits has additional
>  ways of running the event loop (other than just calling "run") for a short
>  period of time.

Right.  For Qt, would that be qApp.processEvents() (i.e. "handle [some] 
pending events"), or QDialog.exec_ (which actually waits for user input in a 
recursively entered eventloop)?
Both are commonly used and must work indeed.

>  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.

Right, but which of the above methods cause problems, and why exactly?

> > (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.

Huh?  Honestly, why should applications modify their __main__ to check for 
*existing* global objects - I think we're talking about a special case here 
which should be handled transparently, don't you agree?

(OK, I *do* occasionally check for existing objects in my __main__, in order 
be able to quickly reload a program with "%run -i", without losing the results 
of some expensive computations, but that's really a special case IMO.)

Have a nice day,
  Hans



More information about the IPython-dev mailing list