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)
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.
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.
If you enter "File Watchers" in the search bar, the corresponding plugin will be hit, so press the "Install" button to install it.
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.
A pop-up for selecting a template will appear, but since there is only \ <custom >, select \ <custom >.
The following four items are required to set Watcher.
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
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 ...".
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>
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