MainWindow.py 是創(chuàng)建的UI文件
import sys
from MainWindow import Ui_MainWindow
from PyQt5.QtWidgets import QApplication,QMainWindow
if __name__=='__main__':
app = QApplication(sys.argv) # 固定寫法
mainWindow = QMainWindow() # 對象實(shí)例
ui = Ui_MainWindow()
ui.setupUi(mainWindow) # 手動創(chuàng)建UI,傳入對象。向主窗口添加控件
mainWindow.show()
sys.exit(app.exec_())