当前位置:网站首页>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_())
得到如下结果
然后,游戏结束
边栏推荐
- Mysql Mac版下载安装教程
- Business Intelligence Platform BI Business Intelligence Analysis Platform How to Choose the Right Business Intelligence Platform BI
- “蔚来杯“2022牛客暑期多校训练营4
- Biotin-C6-amine|N-biotinyl-1,6-hexanediamine|CAS: 65953-56-2
- PyCharm usage tutorial (detailed version - graphic and text combination)
- LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之一:解题思路
- Redisson的看门狗机制
- Postman download localization of installation and use
- Biotin hydrazide HCl|CAS:66640-86-6|Biotin-hydrazide hydrochloride
- RetinaFace: Single-stage Dense Face Localisation in the Wild
猜你喜欢
随机推荐
构建Flink第一个应用程序
PyCharm使用教程(详细版 - 图文结合)
WebGPU 导入[1] - 入门常见问题与个人分享
EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network
Seleniu screenshots code and assign name to the picture
深度学习汇报(4)
如何做好项目管理
Redis分布式锁
PyCharm usage tutorial (detailed version - graphic and text combination)
测试时大量TIME_WAIT
What is the function of page directive contentPage/pageEncoding in JSP page?
MySQL Workbench 安装及使用
科技云报道:实现元宇宙,英伟达从打造基础建设平台开始
Ansible learning summary (11) - detailed explanation of forks and serial parameters of task parallel execution
Biotin - LC - Hydrazide | CAS: 109276-34-8 | Biotin - LC - Hydrazide
PyQt5 (a) PyQt5 installation and configuration, read from the folder and display images, simulation to generate the sketch image
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
Installation and use of pnpm
在 QT Creator 上配置 opencv 环境的一些认识和注意点
UVM之sequence机制