[IPython-User] simple iPython example raises exception on sys.exit()
Matthias BUSSONNIER
bussonniermatthias@gmail....
Tue Jun 5 08:57:13 CDT 2012
Hi,
Le 4 juin 2012 à 23:24, Dave a écrit :
> I'm doing some very simple PySide (and PyQt) tutorials in iPython. One tutorial just creates a window with some sliders to demonstrate slots and signals.
>
> When I close the window of the running demo application, I see this error:
>
> An exception has occurred, use %tb to see the full traceback.
> SystemExit: 0
> To exit: use 'exit', 'quit', or Ctrl-D.
> So I run %tb and get this:
>
> SystemExit Traceback (most recent call last)
> /Workspaces/scratch/<ipython-input-1-88966dcfb499> in <module>()
> 33
> 34 if __name__ == "__main__":
> ---> 35 main()
>
> /Workspaces/scratch/<ipython-input-1-88966dcfb499> in main()
> 29 w.show()
> 30 app.exec_()
> ---> 31 sys.exit(0)
> 32
> 33
>
> SystemExit: 0
Just don't use sys.exit(0) as you are not exiting python, but still running IPython.
Add it if you wish to run your app from a (real) command line and have a return status.
> If I try to execute my code again, I get this:
>
> RuntimeError: A QApplication instance already exists.
This is a PySide Bug that they "won't fix" as they don't consider it a bug.
(see https://github.com/ipython/ipython/issues/1124)
QApplication can only have one instance and quitting an app is apparently not considered a resin sufficient enough do delete the object...
You can use this code from above issues :
...
app=QtGui.QApplication.instance() # checks if QApplication already exists
if not app: # create QApplication if it doesnt exist
app = QtGui.QApplication(sys.argv)
….
to reuse the application instance, it might have a few side effect, (not sure) but you shouldn't be confronted to it if you are starting with qt.
Happy coding,
--
Matthias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120605/3c295977/attachment.html
More information about the IPython-User
mailing list