linux下安装PyQt5+qt-esigner

                

1.安装PyQt5

sudo apt-get install python3-pyqt5

2.安装qt-designer

sudo apt-get install qt5-default qttools5-dev-tools

直接在命令行输入designer即可运行

3.将.ui文件编译程.py文件,需要pyuic命令,uic命令编译的是c语言内容的文件,

pyuic脚本位置在/usr/lib/python3/dist-packages/PyQt5/uic 目录,在.bashrc中添加快捷方式:

alias pyuic="python3 -m PyQt5.uic.pyuic"

运行命令:

pyuic ui文件.ui -o 目标文件.py

便会生成.py的文件(文件为df.py)

linux下安装PyQt5+qt-esigner_第1张图片

为df.py编写主文件(对df.py文件不做任何改变)

import sys  
from PyQt5.QtWidgets import *   
from df import Ui_MainWindow
if __name__ == "__main__":
     app =QApplication(sys.argv)
     form=QMainWindow()  
     myapp=Ui_MainWindow()   #注意点
     myapp.setupUi(form)
     form.show()
     app.exec_()

必须导入df.py文件,Ui_MainWindow()是df文件的类名。

大功告成。


你可能感兴趣的:(python应用配置)