Reputation: 11
I'm learning PyQt4 right now and made a little script which should open a "Hello World!" box. It works the first time I run it, but the second time, the script does nothing and crashes the ipython-notebook kernal, which requires a restart. I'm using the Spyder IDE in Anaconda, under Windows. This is the code:
import sys
from PyQt4 import Qt,QtGui
a = Qt.QApplication(sys.argv)
a.setActiveWindow(QtGui.QMainWindow())
hello = Qt.QLabel("Hello, World")
hello.show()
a.exec_()
Upvotes: 0
Views: 263
Reputation: 11
Sorry, after a bunch of searching I found a duplicate question: simple IPython example raises exception on sys.exit()
The solution, by Ali B, is to do this:
app = QApplication(sys.argv)
app.aboutToQuit.connect(app.deleteLater)
before calling:
sys.exit(app.exec_())
Upvotes: 1