脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - pycharm配置QtDesigner的超详细方法

pycharm配置QtDesigner的超详细方法

2021-08-28 01:03知识追寻者 Python

这篇文章主要介绍了pycharm配置QtDesigner的超详细方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

一、qtdesigner介绍

qt designer 是一款gui界面工具,可以实现将ui设计界面转为python代码的工具;

二、安装 qtdesigner

使用命令

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

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

?
1
conda install pyqt5-tools

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

?
1
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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- 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 文件

参数:

?
1
$filename$ -o $filenamewithoutextension$_rc.py

pycharm配置QtDesigner的超详细方法

到此这篇关于pycharm配置qtdesigner的方法的文章就介绍到这了,更多相关pycharm配置qtdesigner内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/youku1327/article/details/113058608

延伸 · 阅读

精彩推荐