Clemens
Clemens

Reputation: 323

Can't exit PyQt application on 3.7.4 and Spyder

Running on Windows 10 64 bit and Python 3.7.4 (no Anaconda), the basic script from Terminate PyQt Application

import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize    

class HelloWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.setMinimumSize(QSize(640, 480))    
        self.setWindowTitle("Hello world") 

        centralWidget = QWidget(self)          
        self.setCentralWidget(centralWidget)   

        gridLayout = QGridLayout(self)     
        centralWidget.setLayout(gridLayout)  

        title = QLabel("Hello World from PyQt", self) 
        title.setAlignment(QtCore.Qt.AlignCenter) 
        gridLayout.addWidget(title, 0, 0)

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    mainWin = HelloWindow()
    mainWin.show()
    sys.exit( app.exec_() )

does not exit when starting from Spyder. The IPython console simply "idles", but never returns. Running the script from the command prompt (i.e. 'python script.py') works OK.

Switching back to a fresh install of Python 3.7.2, everthing works as expected. The IPython version is in both cases 7.7.0.

In both cases (3.7.2 and 3.7.4) all modules including Spyder had been installed via pip.

Any idea why that is? Is it a Spyder related issue?

Upvotes: 1

Views: 879

Answers (1)

MathewKarthick
MathewKarthick

Reputation: 41

Keeping the Graphics Backend as not "Inline" is creating this problem.

Either change the graphics backend as,

Tools -> Preferences --> IPython Console -> Graphics --> Graphics Backend as Inline

Or Restore the default settings of the Spyder Environment. Which can be done by,

Tools -> Preference --> Reset to Defaults.

Upvotes: 1

Related Questions