Start QGIS Plugin

Start the Plugin Builder plugin and fill necessary inputs. In the first step, we are going to specify name of Python class, module name, short description, etc.

_images/plugin_builder0.png

Fig. 5 Initialization of a new QGIS Plugin

Warning

Don’t use .py (or any extensions) in the module name.

In the next screen, fill longer description of the plugin.

_images/plugin_builder1.png

Fig. 6 Filling longer description text

In the next screen, set visual appearance of the plugin. We will use Tool button with dock widget.

_images/plugin_builder2.png

Fig. 7 Choosing visual representation of a new plugin

There are three options:

  • Tool button with dialog
  • Tool button with dockwidget
  • Processing provider (see QGIS Advanced course)

In the next step, we shell check all the metafiles, the builder will generate for us. We shall leave all checked.

_images/plugin_builder3.png

Fig. 8 Helper metafiles to be generated.

In the next step fill important URLs which is important for later publication of a plugin.

_images/plugin_builder4.png

Fig. 9 Filling required URLs

In the last step, we pick the location of the newly created plugin. You can pick any location in your computer.

Note

Avoid paths containing non-ascii characters.

_images/plugin_builder5.png

Fig. 10 Set output folder for a plugin.

_images/plugin_builder6.png

Fig. 11 Summary

Note

On Microsoft Windows at this point, you may see error message about pyrcc5 script not being available in your system and therefore it could not be compiled. Do not panic, we will compile the plugin manually later with environment set up.

_images/pyrcc5-error.png

Final screen shows summary of the new plugin and QGIS environment settings as well as the next required steps.

_images/plugin_builder7.png

Fig. 12 Plugin summary

Important information are:

  1. Location of the newly created plugin
  2. Default location of all QGIS plugins
  3. Implementation file is called save_views.py
  4. GUI modification shall happen in Qt Designer using the save_views_dialog_base.ui file
  5. Next step is to use pb_tool for the plugin management

There is also information about folders, where QGIS is looking for installed plugins. On Linux, this typically is $HOME/.local/share/QGIS/QGIS3/profiles/default/python/plugins. On MS Windows it may be %APPDATA%\Roaming\QGIS\QGIS3\profiles\default\python\plugins.