1.创建一个qt程序,复制其ui文件至python文件夹,ui界面如下:
`
``
2.vscode 配置pyqt集成环境,右击ui文件进行编译,生成UI_mainwindow.py文件
3.新建main.py,代码如下,运行结果如图
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QGridLayout,QVBoxLayout,QSizePolicy
from PyQt5.QtWidgets import QMessageBox
import Ui_mainwindow
class mywidow(QMainWindow,Ui_mainwindow.Ui_MainWindow):
def __init__(self):
super(mywidow,self).__init__()
self.setupUi(self)
if __name__ =='__main__':
app = QApplication(sys.argv)
w = mywidow()
w.show()
sys.exit(app.exec_())