I'm new to PyQt, and I'm following the tutorial at
http://zetcode.com/gui/pyqt5/firstprograms/ to build a GUI with a "Quit"
push button. When I run it from Spyder, the Quit button doesn't work and
Spyder locks up. I must restart the kernel to recover. However, when I run
this code from the python command line directly, it works just fine and
clicking on the "Quit" button closes the window and terminates the
After several hours of looking, I have not found this issue addressed
anywhere online. Any explanation and/or work-around would be greatly
I am running Windows 10 Home Edition (64b), and using Python 3.5.3, Spyder
3.2 and Qt5.5.1.
from PyQt5.QtWidgets import QWidget, QPushButton, QApplication
from PyQt5.QtCore import QCoreApplication
qbtn = QPushButton('Quit', self)
self.setGeometry(300, 300, 250, 150)
#if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = Example()
# The following "if" logic keeps the kernal from dying every other time.
# Qt does not like more than one QApplication object in the same
# The "instance()" method retrieves the application instance ("None" if
# already created).
if __name__ == "__main__":
app = QCoreApplication.instance()
if app is None:
app = QApplication(sys.argv) # QApp requires the sys arg list.
ex = Example()
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to firstname.lastname@example.org.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.