This is a follow up to why will the application show after sys.exit command?
I'm following this tutorial:
http://zetcode.com/tutorials/pyqt4/firstprograms/
I modified the code slightly to test things
import sys
from PyQt4 import QtGui
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget()
w.resize(250,150)
w.move(300,300)
w.setWindowTitle("Title")
w.show()
sys.exit(app.exec_())
I'm confused as to why there isn't a reference of app and w i'd expect some kind of indication that w is a child or something of app.
I'm running it in Spyder and an IPython interpreter.
For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. All windows are automatically managed by the Application.
You do have to initialize it and to get a hold of it to exec it though.
You must create the Application before any other GUI objects (because they are managed by it).
Detailed Description of the QApplication object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With