destructor_test.py 619 B

12345678910111213141516171819202122232425262728293031323334
  1. import sys
  2. from PyQt5 import QtCore, QtGui, QtWidgets
  3. class MyObj():
  4. def __init__(self):
  5. pass
  6. def __del__(self):
  7. print("##### Destroyed ######")
  8. def parse():
  9. o = MyObj()
  10. raise Exception("Intentional Exception")
  11. class Example(QtWidgets.QWidget):
  12. def __init__(self):
  13. super(Example, self).__init__()
  14. qbtn = QtWidgets.QPushButton('Raise', self)
  15. qbtn.clicked.connect(parse)
  16. self.setWindowTitle('Quit button')
  17. self.show()
  18. if __name__ == '__main__':
  19. app = QtWidgets.QApplication(sys.argv)
  20. ex = Example()
  21. sys.exit(app.exec_())