当前位置:网站首页>PyQt5安装配置(PyCharm) 亲测可用
PyQt5安装配置(PyCharm) 亲测可用
2022-08-02 08:33:00 【L**】
PyQt5安装配置(PyCharm)
pip换源
因为在 PyQt5 下载安装时,只能用pip下载,因此首先把pip换源,换为国内源
国内镜像有:
# 清华
https://pypi.tuna.tsinghua.edu.cn/simple/
# 中科大
https://pypi.mirrors.ustc.edu.cn/simple/
# 阿里云
https://mirrors.aliyun.com/pypi/simple/
# 豆瓣
http://pypi.douban.com/simple/
Win+R ,进入运行界面,输入 %APPDATA% ,进入此目录
在该目录下新建名为pip 的文件夹,然后在其中新建文件 pip.ini。(例如:"C:\Users\Administrator\AppData\Roaming\pip\pip.ini")
在文件中填入一下内容并保存(可替换为上述不同的镜像地址):
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
换完源,就可以使用pip下载了
PyQt5下载
首先进入到需要安装PyQt5的环境中,activate pytorch_gpu
之后,执行命令
pip install sip //这个是pyqt开发商提供的支持包
pip install pyqt5
pip install pyqt5-tools
如果改源不成功的话,可以执行以下命令:
pip install sip //这个是pyqt开发商提供的支持包
pip install PyQt5 -i https://pypi.douban.com/simple
pip install PyQt5-tools -i https://pypi.douban.com/simple
配置PyCharm
这里主要添加两个external tool,Qt Designer和pyuic,前者作为打开qt图形化界面进行UI的编辑,后者是将生成的.ui文件转换为.py文件,从而能够运行它。
①创建Qt Designer
在新建的工程下,File->Settings->Tools->External Tools,点击加号:
Name:可自己定义 建议是: Qt Designer
program:XXX\Anaconda3\Lib\site-packages\qt5_applications\Qt\bin\designer.exe Qt Designer的安装路径
Arguments:不填
Working directory: XXX\anaconda\Lib\site-packages\pyqt5_tools
如图所示:
② 创建pyuic
在新建的工程下,`File->Settings->Tools->External Tools`,点击加号:
Name:可自己定义 建议PyUIC
program:E:\anaconda3\envs\pytorch_gpu\python.exe
Arguments:-m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py
Working directory: $FileDir$

③ 测试
完成后可在pycharm打开Qt Designer,Tools->External Tools->Qt Designer ,这就是我们的目的:

如果一切正常的话:

选择Main Windows,Create
程序猿的第一步当然是仪式性的Hello World
选中一个 label 然后拖拽到window中,Save,建议保存在当前工程目录下!

回到Pycharm 就会多了一个.ui文件
选中该文件,右击,External Tools,PyUIC,这个时候会生成一个.py文件
写一个主类来测试一下:
import sys
import HelloWorld
from PyQt5.QtWidgets import QApplication, QMainWindow
if __name__ =='__main__':
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = HelloWorld.Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
得到如下结果
然后,游戏结束
边栏推荐
- Redis分布式锁入门
- ip地址那点事(二)
- Jenkins--基础--6.1--Pipeline--介绍
- day_05 time 模块
- LeetCode_2357_使数组种所有元素都等于零
- 小康股份更名赛力斯,如何走出一条高端产品的“丝绸之路”?
- A little bit of knowledge - why do not usually cook with copper pots
- houdini 求出曲线的法向 切线以及副法线
- How Engineers Treat Open Source --- A veteran engineer's heartfelt words
- Golang ORM框架 — GORM
猜你喜欢
随机推荐
(Note)阿克西斯ACASIS DT-3608双盘位硬盘阵列盒RAID设置
PostgreSQL learning summary (11) - PostgreSQL commonly used high-availability cluster solutions
Technology Cloud Report: To realize the metaverse, NVIDIA starts from building an infrastructure platform
Seleniu screenshots code and assign name to the picture
How to use postman
Detailed explanation of calculation commands in shell (expr, (()), $[], let, bc )
Gorilla Mux 和 GORM 的使用方法
Three types of [OC learning notes] Block
day_05 time 模块
自定义View实现波浪荡漾效果
postman使用方法
High imitation [Huawei consumer business official website] and wonderful animation analysis: practice embedding JS code in low-code platform
深度学习汇报(4)
自定义卡包效果实现
Biotin - LC - Hydrazide | CAS: 109276-34-8 | Biotin - LC - Hydrazide
JSP页面中page指令有哪些属性及方法可使用呢?
Hikari连接池源码解读
EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network
R language plotly visualization: use the plotly visualization model to predict the true positive rate (True positive) TPR and false positive rate (False positive) FPR curve under different thresholds
Jenkins--基础--6.2--Pipeline--语法--声明式









