开发环境

PyCharm 2018.3.3
python3.7

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

 

1 安装pyqt5

pip install PyQt5-tools

2 配置PyCharm

2.1 配置设计器

PyCharm开发GUI之PyQt安装 Python 第1张

 

其中,program为C:\Users\edwin\AppData\Local\Programs\Python\Python37\Lib\site-packages\pyqt5_tools\designer.exe

arguments为$FileName$

working directory为$FileDir$

使用方法,新建 

PyCharm开发GUI之PyQt安装 Python 第2张

 编缉

PyCharm开发GUI之PyQt安装 Python 第3张

2.2 配置ui文件生成为py代码工具

PyCharm开发GUI之PyQt安装 Python 第4张

其中,program定义为C:\Users\edwin\AppData\Local\Programs\Python\Python37\python.exe

arguments为-m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py

working directory为$FileDir$

使用时

PyCharm开发GUI之PyQt安装 Python 第5张

 

3 代码示例


from ui.main import Ui_Form
from PyQt5 import QtCore
from PyQt5 import QtWidgets



if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
w = QtWidgets.QMainWindow()
ex = Ui_Form()
ex.setupUi(w)
w.show()
sys.exit(app.exec_())

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄