让 PyQt5 和 Qt Designer 与 PyCharm 良好配合存在很多小挑战,但在完成所有小步骤后,我不禁想知道我是否错过了显而易见的事情。
集成 PyCharm 和 Qt Designer 的最直接方法是什么?
到目前为止我做了什么:
- 安装 Qt 设计器
- 将其设置为外部工具
- 打开
设置 > 工具 > 外部工具
- 添加新工具
- 将参数设置为
$FilePath$
,将工作目录设置为$Projectpath$
- 打开
- 右键单击项目资源管理器中的
.ui
文件,然后从那里启动 Qt Designer - 从“设置”中设置文件观察器,监视 Qt UI Designer Forms 的更改,并使用正确的参数运行
pyuic5
来为我的生成匹配的
.py
>.ui
我正在寻找的答案:
- 如何加强 Qt Designer 和 PyCharm 之间的循环?具体来说,可以通过 PyCharm 中的简单双击打开 Qt Designer,甚至可以在 PyCharm 的选项卡中打开 Qt Designer?
- 是否有更好的整体工作流程可以实现相同的效果,但我在这里缺少?
最佳答案
在 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.
关于python - 集成 Qt Designer 和 PyCharm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58599351/