How to make a QGIS plugin (package generation)

Overview

QGIS allows you to write plugins in Python. You can use Python in various ways in conjunction with QGIS, and writing plugins is one way to use it.

What you can do with QGIS and Python is described on the following page of the official website. http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/

Corresponding page of the official website about plugin creation http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html#developing-plugins

Procedure article in English by a user (but Googler) http://www.qgistutorials.com/en/docs/building_a_python_plugin.html

There is a plug-in that can generate the required set of files, so here are the steps to prepare a set of files using it.

Installation of necessary tools

--Plugin Builder (Plugin Generation Plugin) --Qt Designer (GUI editing tool) - Qt Creator on Mac (http://qt-project.org/downloads) --Qt Designer on Ubuntu (installed with apt-get.'sudo apt-get install qt4-designer') - WinPython on Windows (http://winpython.sourceforge.net/) --Plugin Reloader (A plugin that can reflect the modified contents without restarting the application when modifying the function on the plugin. It is not essential)

Try using

Launch Plugin Builder from the QGIS Plugins menu.

スクリーンショット 2015-08-01 15.53.03.png

Enter the required items and press the OK button. You will be asked for the storage location. You can save it anywhere, but QGIS will not recognize it unless you save it in a location that QGIS recognizes as a plugin folder.

スクリーンショット 2015-08-01 16.34.37.png

For Mac, the following location is where to put the default plugins. /Users/(username)/.qgis2/python/plugins

スクリーンショット 2015-08-01 15.55.19.png

Folders with a. Are not displayed in the default Finder and cannot be moved in the GUI, but you can be sure to select the menu "Move"-> "Move to Folder ..." and enter the above file path. Or move the folder with CUI.

Plugin icon

You can customize the icon image to be displayed on QGIS. However, you need to convert it so that QGIS can read it with the provided tool. Although this file is required, it is not included in the file generated by this tool, so you need to execute the conversion instruction once regardless of whether you customize it or not. Execute the following command in the plugin directory.

pyrcc4 -o resources_rc.py resources.qrc

Resources.qrc that describes the existence of the icon image in XML format is generated.

UI editing

-Edit ***._dialog_base.ui ( is the plugin name) with Qt Creator.

スクリーンショット 2015-08-01 16.41.29.png

Describe the plug-in function in a file

-***. Py ( is the plugin name). --When loading an external library, write it at the beginning of this file. -The minimum required functions are: --init Required to be accessible from QGIS --intGui () Executed when the plugin is loaded --unload () Executed when the plugin exits --Run (self) Describe the contents of the plugin

Recommended Posts

How to make a QGIS plugin (package generation)
[Blender] How to make a Blender plugin
How to make a Python package using VS Code
How to make a Japanese-English translation
How to make a slack bot
How to create a Conda package
How to make a crawler --Advanced
How to make a recursive function
How to make a deadman's switch
How to make a crawler --Basic
How to make a Python package (written for an intern)
How to add a package with PyCharm
[Python] How to make a class iterable
How to make a Backtrader custom indicator
How to make a Pelican site map
Spigot (Paper) Introduction to how to make a plug-in for 2020 # 01 (Environment construction)
How to make a dialogue system dedicated to beginners
How to make Spigot plugin (for Java beginners)
How to make a dictionary with a hierarchical structure.
I read "How to make a hacking lab"
How to make Substance Painter Python plugin (Introduction)
How to make a shooting game with toio (Part 1)
Basics of PyTorch (2) -How to make a neural network-
How to study Bukkit Plugin
How to hack a terminal
How to make a Cisco Webex Teams BOT with Flask
[Python] How to make a list of character strings character by character
Make a tky2jgd plugin with no practicality in QGIS Part 2
How to make a multiplayer online action game on Slack
How to make a hacking lab-Kali Linux (2020.1) VirtualBox 64-bit Part 2-
Make a tky2jgd plugin with no practicality in QGIS Part 1
How to make a hacking lab-Kali Linux (2020.1) VirtualBox 64-bit edition-
How to make a simple Flappy Bird game with pygame
How to register a package on PyPI (as of September 2017)
How to write a Python class
How to put a symbolic link
How to create a virtual bridge
How to use Nix package manager
How to create a Dockerfile (basic)
[Blender] How to make Blender scripts multilingual
How to delete a Docker container
How to create a config file
How to make a string into an array or an array into a string in Python
How to make a surveillance camera (Security Camera) with Opencv and Python
[C language] How to create, avoid, and make a zombie process
How to make a .dylib library from a .a library on OSX (El Capitan)
Slack --APIGateway --Lambda (Python) --How to make a RedShift interactive app
How to make a unit test Part.1 Design pattern for introduction
[Python] How to make a matrix of repeating patterns (repmat / tile)
How to make Word Cloud characters monochromatic
How to make Selenium as light as possible
How to create a clone from Github
Tweet in Chama Slack Bot ~ How to make a Slack Bot using AWS Lambda ~
How to package and distribute Python scripts
How to split and save a DataFrame
How to build a sphinx translation environment
How to create a git clone folder
Qiita (1) How to write a code name
How to draw a graph using Matplotlib
[Python] How to convert a 2D list to a 1D list
Try to make a kernel of Jupyter