当前位置:网站首页>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版下载安装教程

EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network

C语言基础_共用体

Biotin-C6-amine|N-biotinyl-1,6-hexanediamine|CAS: 65953-56-2

Biotin hydrazide HCl|CAS:66640-86-6|Biotin-hydrazide hydrochloride

深度学习汇报(4)

了解下C# 不安全代码

houdini 求出曲线的法向 切线以及副法线

Jenkins--部署--3.1--代码提交自动触发jenkins--方式1

Jenkins--基础--5.4--系统配置--全局工具配置
随机推荐
Wang Xuegang - compiled shipment line file
十大免费cms建站系统介绍推荐
R language plotly visualization: plotly visualizes the scatter plot of the actual value of the regression model and the predicted value of the regression, analyzes the prediction performance of the re
Pycharm (1) the basic use of tutorial
Seleniu screenshots code and assign name to the picture
查看变量的数据格式
Gorilla Mux 和 GORM 的使用方法
QT web development - Notes - 3
LeetCode_2358_分组的最大数量
pycharm的基本使用教程(1)
四字节的float比八字结的long范围大???
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
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之一:解题思路
UVM事务级建模
Redisson实现分布式锁
js函数防抖和函数节流及其使用场景
BGP solves routing black hole through MPLS
【论文阅读】Distilling the Knowledge in a Neural Network
What is the function of page directive contentPage/pageEncoding in JSP page?
unity pdg 设置隐藏不需要的节点以及实现自动勾选自动加载项