K
K
kuzubov2013-03-16 19:42:06
Python
kuzubov, 2013-03-16 19:42:06

Traceback error when exiting a Python2.7 + PyQt4 program?

I wrote a lot of plugins for 3D packages in Python + PyQt and they all ran inside the same packages for which they were written. And so I decided to write just a standalone application on the same bundle. Took the simplest example straight from the documentation:

import sys
from PyQt4 import QtGui

def main():
    app = QtGui.QApplication(sys.argv)
    w = QtGui.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

Fulfilled ... A window appeared, rejoiced and closed it. And in python output I immediately saw an error:
Traceback (most recent call last):
  File "D:\Temp\test_qt3.py", line 14, in <module>
    main()
  File "D:\Temp\test_qt3.py", line 11, in main
    sys.exit(app.exec_())
SystemExit: 0

Somehow it scares me that the application from the documentation gives an error when exiting. I also tried more complex examples from them - and all exits end with such an error. Of course, I can find fault and such an output is standard for all PyQt applications - but the error annoys me and I don’t like warnings to even be in the program, not to mention errors ...
In general, the question is this - what is wrong in the exit from program and why this error is generated and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dotsquid, 2013-03-16
@dotsquid

It's not a mistake. This is the default behavior of sys.exit(): it throws a SystemExit exception. Read more in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question