Ami*_*ani 4 python pyqt4 python-3.x
我有这段代码,可以正常工作:
import sys
from PyQt4 import QtGui
def main_window():
app = QtGui.QApplication(sys.argv)
screen = QtGui.QDesktopWidget().screenGeometry()
widget = QtGui.QWidget()
widget.setWindowTitle("Center!")
widget.setGeometry(200, 100, screen.width() - 400, screen.height() - 200)
label = QtGui.QLabel(widget)
label.setText("Center!")
label.move(widget.frameGeometry().width() / 2, widget.frameGeometry().height() / 2)
widget.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main_window()
Run Code Online (Sandbox Code Playgroud)
现在在我说的那一行中sys.exit(app.exec_()),我也可以说app.exec_(),两者的作用相同。
那么有什么区别,为什么有必要写sys.exit()?
提前致谢。
| 归档时间: |
|
| 查看次数: |
2334 次 |
| 最近记录: |