Without seeing all of your code, I assume that you are missing the sys.exit() bit.
For your specific code, sys.exit(segmentation.exec_()) will be what you need.
segmentation = qt.QApplication(sys.argv) main = qt.QWidget() main.show() sys.exit(segmentation.exec_())
A bit of detailed information about what is happening here.
segmentation = qt.QApplication(sys.argv) creates the actual application.
main = qt.QWidget() and main.show() creates a widget and then displays.
When executing a python script, this does exactly what you say:
- Application creation
- Widget creation
- Show widget
- completeness. The end of the script.
What sys.exit() does is the pure closure of the python script. segmentation.exec_() starts the background processing of the QT event. After segementation.exec_() (the user closes the application, your software closes the application or detects an error), it returns a value, which is then passed to the sys.exit() function, which, in turn, terminates the python process.
source share