python - PyQt Window construction -
Can someone tell me the difference between the following two code examples? Why the top is not working? It executes without error, but the window does not remain open. Importing QtGui from PyQt4 import SYS app = QtGui.QApplication (sys.argv) QtGui.QMainWindow (). Show () ap .exec_ ()
And: QtGui import from the PyQt4 import SYS app = QtGui.QApplication (sys.argv) win = QtGui.QMainWindow () Win.show () app .exec_ ()
in in the second code: QtGui.QMainWindow (). Show () You are creating an object of
QMainWindow and you are showing it but if you do not save that example of
QMainWindow in your memory Eventually the drone collection of the dragon removes that example and your
QMainWindow does not show anymore
win = QtGui.QMainWindow () You can save the object object from
QMainWindow to
win your memory. Python does not consider it as garbage because it is in use and therefore your window remains open
Comments
Post a Comment