soc*_*ket 33 python qt pyqt python-3.x pyqt5
我使用Python 3和PyQt5.这是我的测试PyQt5程序,重点关注最后两行:
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
class window(QWidget):
def __init__(self,parent=None):
super().__init__(parent)
self.setWindowTitle('test')
self.resize(250,200)
app=QApplication(sys.argv)
w=window()
w.show()
sys.exit(app.exec())
#sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)
我知道exec是Python中的语言关键字.但官方PyQt5文档 上的代码(特别是退出部分的Object Destruction).我看到这个例子显示使用app.exec()它让我感到困惑.
当我在我的机器上测试它时.我发现与我的目的没有任何明显的区别.有和没有_产生相同的输出没有时间差.
我的问题是:
app.exec()吗?喜欢与Python的内部冲突exec?我怀疑是因为两人exec正在执行某些事情.