Integrating Customized Scripts and Commands into PyCharm Pro

This article illustrates the steps to integrate any customized script or command into PyCharm Pro 2020. The procedure should be identical across major operating systems. 

The example shown here will issue a pyuic5 command to generate a PyQt5 GUI class from a Qt Designer file.

Setup

  1. Open File -> Settings -> Tools -> External Tools
  2. Add an entry named “pyuic5” (or your preferred name).
  3. Set the entry as Figure 1 below. 
Figure 1: Add an external command. An $MACRO$ is added by the "+" button in the right side.

The entry issues the following command which converts your.ui into your.py:
    /path/to/pyuic5 -x /path2/to/your.ui -o /path2/to/your.py

Usage

Right click on the file to be converted and select External Tools -> pyuic5 as shown in Figure 2.

Figure 2: Use the added entry of the customized command.

Appendix: Installing PyQt5 and Qt Designer


PyQt5 (open source version) and Qt Designer can be installed via pip or pip3.
    pip install pyqt5 pyqt5-tools
In debian 10 with KDE Plasma 5 desktop pre-installed, Qt Designer should be shipped and searchable by default.

Qt Designer in Linux (KDE Plasma 5 desktop environment, dark theme)

Comments