[PYTHON] The strongest PySide / PyQt development environment is also PyCharm

In the article Recommendation of the strongest Python development environment PyCharm, I introduced how PyCharm is the strongest development environment. In the development of PySide / pyQt, PyCharm is still the strongest. (The article is written for PySide, but it can be replaced with PyQt)

Automatically convert ui files to py files

When creating a ui file using QtDesigner, I think that there are many people who convert it manually or semi-automatically.

I wrote an article Automatically convert ui files to py files when they are updated in PySide, but PyCharm monitors ui files by itself. It will convert automatically.

Install the File Watchers plugin

File monitoring requires the installation of the `File Watchers` plugin.

Open the Settings dialog (Ctrl + Alt + S), select "Plugins", and press "Install JetBrains plugin ..." from there.

qt_pycharm01.png

If you enter "File Watchers" in the search bar, the corresponding plugin will be hit, so press the "Install" button to install it.

qt_pycharm02.png

You need to restart PyCharm after installing the plugin.

After restarting, open the Settings dialog (Ctrl + Alt + S) again, select "Tools" → "File Watchers", and press the "+" button on the right side.

qt_pycharm03.png

A pop-up for selecting a template will appear, but since there is only \ <custom >, select \ <custom >.

qt_pycharm04.png

The following four items are required to set Watcher.

qt_pycharm05.png
Setting Contents
Name Enter an appropriate name, in the example "pyside"-uic」
File Type Qt UI Designer Form
Program pyside-uic path
Arguments -o $FileDir$/$FileNameWithoutExtension$_ui.py $FilePath$

The Arguments in the above example are set to convert "\ * .ui" to "\ * _ ui.py". Please rewrite this item according to your own rules.

Now that the settings are complete, the ui file will be automatically converted to a py file.

Reference URL Using File Watchers

Add "Qt UI Designer Form" to the file template

Adding "Qt UI Designer Form" to the file template is very convenient because you can quickly add the Form file.

To set the file template, right-click the file and select "New"-> "Edit File Templates ...".

pycharm6.png

Add a template with the "+" button, enter an appropriate distinguished name in Name, and enter "ui" in Extension. Finally, set the template contents, but if it is a UI template of MainWindow, set as follows.

MainWindow UI template


<ui version="4.0" >
 <author></author>
 <comment></comment>
 <exportmacro></exportmacro>
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>800</width>
    <height>600</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>MainWindow</string>
  </property>
  <widget class="QMenuBar" name="menubar" />
  <widget class="QWidget" name="centralwidget" />
  <widget class="QStatusBar" name="statusbar" />
 </widget>
 <pixmapfunction></pixmapfunction>
 <connections/>
</ui>
qt_pycharm06.png

Summary

After all, PyCharm was the strongest.

There are other features that may be useful for Qt development, so I'll update this article from time to time.

Recommended Posts

The strongest PySide / PyQt development environment is also PyCharm
The strongest Python integrated development environment PyCharm
The strongest Python development environment PyCharm's recommendation
Set the environment variables required for PySide (Qt4) and PyQt (Qt5)
Checking the NAOqi Python development environment
Prepare the development environment with anyenv
About the development environment you are using
Prepare the development environment for keyhac for Mac
If you think the PyCharm environment is broken, it's because of the file name
Build the fastest Django development environment with docker-compose
Create the strongest calculator environment with Sympy + Jupyter
Instantiation of the BOX development environment created earlier
[Web development with Python] query is also redirect