python - 集成 Qt 设计器和 PyCharm
问题描述
要让 PyQt5 和 Qt Designer 与 PyCharm 配合得很好,有很多小挑战,但是在完成所有小步骤之后,我不禁想知道我是否错过了显而易见的事情。
集成 PyCharm 和 Qt Designer 最直接的方法是什么?
到目前为止我做了什么:
- 安装 Qt 设计器
- 将其设置为外部工具
- 打开
Settings > Tools > External tools
- 添加新工具
- 将参数设置为
$FilePath$
,工作目录设置为$Projectpath$
- 打开
- 在项目资源管理器中右键单击
.ui
文件并从那里启动 Qt Designer - 从设置中设置一个文件观察器,观察 Qt UI 设计器表单的更改并
pyuic5
使用正确的参数运行以生成匹配.py
我的.ui
我正在寻找的答案:
- 如何收紧 Qt Designer 和 PyCharm 之间的循环?具体来说,Qt Designer 是否可以通过 PyCharm 的简单双击打开,甚至可以在 PyCharm 的选项卡中打开?
- 是否有更好的整体工作流程可以实现相同的目标,而我在这里缺少?
解决方案
在 Pycharm 中集成 QT Designer 的分步说明:
1. Python 3.7 = C:\Users\x\PycharmProjects\Hello\venv\Scripts\python.exe
2. Pip install following:
a. PyQt5
b. PyQt5-tools
3. Location of QT designer.exe, which is located in - C:\Users\x\PycharmProjects\Hello\venv\Scripts\designer.exe
4. For QT Designer : File -> Settings -> Tools -> External Tools -> create (+)
a. Name : QTdesigner
b. Program : C:\Users\x\PycharmProjects\Hello\venv\Scripts\designer.exe
c. Arguments : NONE
d. Working directory : $ProjectFileDir$
OK
5. For converting UI file to Py file Pyuic : File -> Settings -> Tools -> External Tools -> create (+)
a. Name : PyUIC
b. Program : C:\Users\x\PycharmProjects\Hello\venv\Scripts\pyuic5.exe
c. Arguments : -x $FileName$ -o $FileNameWithoutExtension$.py
d. Working directory : $ProjectFileDir$
OK
6. Click Tools -> External Tools -> QTdesigner
Design your UI and save it as X.ui
7. You will have X.ui located in the Project file,
a. right click on X.ui
b. External Tools -> PyUIC
c. Success
8. You will be able to see X.py file in the projects folder
9. Run X.py
10. You should be able to see your GUI Application.
推荐阅读
- numpy - 为什么我们在展平图像后进行转置
- javascript - Javascript/jquery 函数正在计算我的参数的结果,即使它是一个字符串?
- resources - 如何将 JAR 之外的资源加载到 MultiResourceItemReader 中?
- python - 无法理解python中的类
- java - 在 Repository 类中获取 LiveData 并在无死循环的情况下更新数据库中的数据
- c - 为 PIC24 重新定义寄存器掩码以提高可读性是不好的做法吗?
- python - 当在其中使用全局变量时,函数变得不可迭代
- java - 如何为不同的测试环境配置不同的 Kafka Brokers/endpoints?
- reactjs - ReactJS:无法读取未定义的属性“绑定”
- python - Python:如何从大熊猫数据框中创建多个 CSV,而不复制 CSV 中创建的记录