1.安装pyqt5相关包
pip install PyQt5 -i https://pypi.douban.com/simple
pip install PyQt5-tools -i https://pypi.douban.com/simple
2.打开File->Setting->Tools->External Tools
1)添加 QtDesigner
Program:D:\python\PycharmProjects\test\venv\Scripts\designer.exe(按照自己的路径填写)
Working directory:$FileDir$ (照填)
2)添加 pyuic5
Program:D:\python\PycharmProjects\test\venv\Scripts\python.exe(按照自己的路径填写)
Arguments:-m PyQt5.uic.pyuic
F
i
l
e
N
a
m
e
FileName
FileName -o
F
i
l
e
N
a
m
e
W
i
t
h
o
u
t
E
x
t
e
n
s
i
o
n
FileNameWithoutExtension
FileNameWithoutExtension.py(照填)
Working directory:$FileDir$ (照填)
3.使用方法
打开qtdesinger
随便生成一个ui
根据ui转换为py文件
在目录中会生成文件first.py
下面添加main.py,因为ui文件命名为first,所以import是first
import sys
import first
from PyQt5.QtWidgets import QApplication, QMainWindow
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = first.Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
运行main就完成了