环境
windows10x64、pycharm、python3.7
思路
1、使用QTDesigner画界面
2、使用cx_Freeze打包
下载
1、PyQt5_Tools-5.7.dev1-py3-none-any.whl(https://pan.baidu.com/s/1UBGpzSB8S6ep5K5mcnMBCg 提取码:lim0)
2、cx_Freeze-6.5.3-cp37-cp37m-win_amd64.whl(https://pan.baidu.com/s/13YOTc17PEG8URWFbdmHE5w 提取码:yvm9)
安装
1、pip安装PyQt5、PyQt5-tools
2、pip安装cx_Freeze
配置pycharm的External Tools
1、创建QTDesigner:图形化工具,产出.ui文件
name:QTDesigner
graoup:External Tools
program:designer.exe的路径
working directory:$ProjectFileDir$

2、创建PyUIC:输入->QTDesigner保存的.ui文件,产出->.py文件
name:PyUIC
graoup:External Tools
program:python.exe的路径
arguments:-m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py
working directory:$ProjectFileDir$

3、查看成果:

将QTDesigner画的界面转换为py文件
路径1:Pycharm->Tools->External Tools->QTDesigner
路径2:Pycharm->Tools->External Tools->PyUIC
1、使用QTDesigner创建一个Form,添加想要的控件并设置响应的属性值

2、生成.ui文件,保存到python项目路径下
3、点击PyUIC,在相同目录下生成与.ui文件同名的.py文件,内容如下:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'untitled.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(

最低0.47元/天 解锁文章

304

被折叠的 条评论
为什么被折叠?



