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

Hans Meine hans_meine@gmx....
Fri Feb 12 05:25:04 CST 2010


On Friday 12 February 2010 12:11:04 Gael Varoquaux wrote:
> On Fri, Feb 12, 2010 at 12:06:50PM +0100, Hans Meine wrote:
> > Do I?  I see it more like a minimal setup function for opening the main
> > window, which is all I care about.  The QApplication line is only there
> > to make the stuff below work (with Qt, as with most toolkits AFAIK, I
> > would otherwise get an error because the widgets will rely on global
> > state being initialized by the application constructor).
> 
> Use:
> 
>     app = QtGui.QApplication.instance()
> 
> That should suit your needs and avoid creating an QApplication if it
> already exists.

Thanks for the hint, but the docs say:
  "If no instance has been allocated, null is returned."

Furthermore, what about app.exec_?  I thought I needed sth. like:

if __name__ == "__main__":
	hasApp = QtGui.QApplication.instance()
	if not hasApp:
		import sys
		app = QtGui.QApplication(sys.argv)

	mw = BeverageMainWindow()
	mw.resize(800, 600)
	mw.show()

	if not hasApp:
		sys.exit(app.exec_())

That's OK, I can do that, but I would still prefer not to have to change every 
application just for the occasional debugging session in ipython.

And how do you want to communicate this to all ipython users?  I mean - there 
needs to be some documentation about this boilerplate code for every toolkit, 
and every user needs to be aware of this and get it right.

I fully agree that the above code has a much better design, is more well-
behaved, but you know very well that most programs are not so well-behaved, 
and consequently you'll lock out a large fraction of existing programs from 
being %run from IPython.  And from a user's POV, this will even appear to be a 
regression, even if previous support for that was buggy - there *was* support 
for it.

I'd say not looking at other program's deficiencies, but closing the eyes and 
adding some proper hack would be much more in the spirit of IPython.

Best,
  Hans


More information about the IPython-dev mailing list