Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Qt Designer and PyCharm

There are plenty of minor challenges getting PyQt5 and Qt Designer to play nice with PyCharm, but after getting all the small steps in place, I cannot help but wonder if I missed the obvious.

What is the most straightforward way to integrate PyCharm and Qt Designer?

What I did so far:

  • Install Qt Designer
  • Set it up as an external tool
    • Open Settings > Tools > External tools
    • Add a new tool
    • Set the Arguments as $FilePath$ and the Working directory as $Projectpath$
  • Rightclick .ui files in the project explorer and launch Qt Designer from there
  • Set up a File Watcher from Settings, watching for changes to Qt UI Designer Forms and running pyuic5 with the right arguments to generate the matching .py for my .ui

Answers I'm looking for:

  • How can you tighten the loop between Qt Designer and PyCharm? Specifically, can the Qt Designer be opened on a simple double-click from PyCharm or even in a tab in PyCharm?
  • Is there a better overall workflow that achieves the same, that I'm missing here?
like image 855
Grismar Avatar asked Oct 28 '19 22:10

Grismar


People also ask

Can I use PyQt in PyCharm?

As a cross-platform toolkit, PyQt can run on all major operating systems (Unix, Windows (Mac). This article describes how to install Python + PyCharm + PyQt5.

Does Qt Designer work with Python?

To create a GUI for your windows and dialogs in PyQt, you can take two main paths: you can use Qt Designer, or you can hand code the GUI in plain Python code.


1 Answers

Step by Step instruction on Integrating QT Designer in Pycharm :

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.
like image 142
Joker Avatar answered Nov 01 '22 20:11

Joker