手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

python下.ui转为.py文件,并用另一.py调用显示

时间:2024-10-14 10:17:25

1、在pycharm->tools->External tools -> QTdesigner ,运行QTdesigner生成界面。

python下.ui转为.py文件,并用另一.py调用显示

2、重要步骤1: pycharm 工程里找到UItest.ui 陴查哉厥右键,->External tools ->pyuic点击,生成 UItest.py 文件。生成后工程里能看到!

python下.ui转为.py文件,并用另一.py调用显示

3、重要步骤2:另建一个新的.py 加入 import sysfrom UItest import Ui_MainWindowfrom P烤恤鹇灭yQt5 import QtWidgetsclass mywindow(QtWidgets.QWidget, Ui_MainWindow): # 这个地方要注意Ui_MainWindow def __init__(self): super(mywindow, self).__init__() self.setupUi(self) #。。。加自己的函数等if __name__=="__main__": app=QtWidgets.QApplication(sys.argv) myshow=mywindow() myshow.show()#显示 sys.exit(app.exec_())

python下.ui转为.py文件,并用另一.py调用显示

4、重要步骤3: 在.ui文件生成那个的.py文件里 注释掉Ma坡纠课柩inWindow开头的三句# MainWindow.setCentralWidget(self.centralwidget)# MainWindow.setMenuBar(self.menubar)# MainWindow.setStatusBar(self.statusbar)

python下.ui转为.py文件,并用另一.py调用显示

5、运行刚才新建的.pyOK!

python下.ui转为.py文件,并用另一.py调用显示
© 手抄报圈