网络编程
位置:首页>> 网络编程>> Python编程>> pycharm配置QtDesigner的超详细方法

pycharm配置QtDesigner的超详细方法

作者:知识追寻者  发布时间:2022-09-07 13:35:01 

标签:pycharm,配置,QtDesigner

一、QtDesigner介绍

Qt Designer 是一款GUI界面工具,可以实现将UI设计界面转为Python代码的工具;

二、安装 QTdesigner

使用命令


pip install PyQt5-tools -i http://pypi.douban.com/simple --trusted-host=pypi.douban.com

如果已经安装过 anaconda 可以直接使用 如果命令进行安装


conda install PyQt5-tools

安装完后找到 安装包的路径,比如我的安装路径如下


C:\soft\anaconda\envs\data_dig\Lib\site-packages\pyqt5_tools\Qt\bin\designer.exe

pycharm配置QtDesigner的超详细方法

三、配置QTdesigner

打开 pycharm 进入工程 , 点击 file–>settings —.tools— extends Tools 的加号进行配置扩展程序

路径:designer 的安装路径

参数:$FileDir$

工作目录$ProjectFileDir$

pycharm配置QtDesigner的超详细方法

配置完打开 pycharm 的扩展工具即可在当前工程打开designer;

pycharm配置QtDesigner的超详细方法

打开后随意点击控件拖入 框中,表示配置成功;

pycharm配置QtDesigner的超详细方法

保存当前文件到当前工程命名为hello.ui;

四 配置 pyuic5

pyuic5 是将 desginer 生成的ui文件转为 python文件

同样在扩展工具中添加配置

因为我的环境都是anaconda安装的所以在C:\soft\anaconda\envs\data_dig\Scripts\下就找到了,然后进行配置;

参数:$FileName$ -o $FileNameWithoutExtension$.py

工作目录:$ProjectFileDir$

pycharm配置QtDesigner的超详细方法

配置完成后就可以将刚刚hello.ui 文件进行点击右键,选择扩展程序 PyUIC 就自动在工程目录下将hello.ui 文件转为了 hello.py


# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'hello.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_Form(object):
def setupUi(self, Form):
 Form.setObjectName("Form")
 Form.resize(400, 300)
 self.pushButton = QtWidgets.QPushButton(Form)
 self.pushButton.setGeometry(QtCore.QRect(50, 60, 75, 23))
 self.pushButton.setObjectName("pushButton")
 self.radioButton = QtWidgets.QRadioButton(Form)
 self.radioButton.setGeometry(QtCore.QRect(70, 170, 89, 16))
 self.radioButton.setObjectName("radioButton")
 self.toolButton = QtWidgets.QToolButton(Form)
 self.toolButton.setGeometry(QtCore.QRect(230, 140, 37, 18))
 self.toolButton.setObjectName("toolButton")

self.retranslateUi(Form)
 QtCore.QMetaObject.connectSlotsByName(Form)

def retranslateUi(self, Form):
 _translate = QtCore.QCoreApplication.translate
 Form.setWindowTitle(_translate("Form", "Form"))
 self.pushButton.setText(_translate("Form", "PushButton"))
 self.radioButton.setText(_translate("Form", "RadioButton"))
 self.toolButton.setText(_translate("Form", "..."))

五 配置 pyrcc5

pyrcc5.exe 是将 资源文件转为 Python 文件

参数:


$FileName$ -o $FileNameWithoutExtension$_rc.py

pycharm配置QtDesigner的超详细方法

来源:https://blog.csdn.net/youku1327/article/details/113058608

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com