Look at the next MWE.
import sys
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.button = QPushButton('Bham!')
self.setCentralWidget(self.button)
self.button.clicked.connect(self.btnClicked)
def btnClicked(self):
print(sys.excepthook)
raise Exception
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
app.exec_()
I have a number of questions. I do not know if they are all connected (I think so), so forgive me if they are not.
When I run the above code from the terminal, everything is fine. The program starts if I press a button, it prints a trace and dies. If I run it inside the IDE (I tested Spyder and PyCharm), the trace is not displayed. Any idea why? Essentially the same question was raised in other posts also on SO, here and here . Do not indicate this as a duplicate of any of them; read please.
, . , ! , , AFAIK excepthook , . , .
, , Qt , , , , . , excepthook , PyQt, , ( , , print).
FYI, Python 3.5 PyQt 5.6, , PyQt 5.5. , .