Create Your Own Custom QGIS Plugin
Create Your Custom QGIS Plugin
In this sample tutorial we’re going to create a sample
plugin that displays a simple message , the standard “Hello World”
in the QGIS Interface.
Prerequisites
In this tutorial we needed the following
Software
QGIS Software required
(I use version: 2.12.1 Lyon or any other versions current is QGIS 3.8 Zanzibar)
Click the link to download the software appropriate to your platform (https://qgis.org/en/site/forusers/download.html) the software is open source
Platform
Operating System : In this tutorial Windows 7
Steps on Creating Your Custom Quantum (QGIS) Plugin
1 1. Click on Start Menu ->Click QGIS
2. QGIS will
then start , Now click on the Plugins
Menu , the Plugins menu dropdown appears.
4. The QGIS Plugin Builder Appears.
6. Click on Next Button
7. In the about Section put in
This plugin displays Hello World Message. A simple plugin
Then click next
8. For the template choose Tool Button with dockwidget what it does is that it creates
a section in QGIS interface by which we can display the Hello World Message.
On the text for Menu Item we put in Display Hello World Message , for the Menu , we put in Plugins ,
this is the portion of the menu where the Menu Item “Display Hello World
Message” is placed
Dockwidget area is Left
so where is it? It is placed on the left part of the QGIS Interface , once it
is activated later
9. Click on Next ,Leave the next prompt as is, then click
next . Click the Checkbox as Flag the plugin as experimental .Click Next , the
default directory is displayed
This is where the HelloWorld class folder you input just a while ago will
be placed. Please take note of this directory. This is also the repository of
all our future plugin coding modules. Click on Generate .
The plugin builder results appears
10. Click Ok
Now as you see using the Windows Explorer the HelloWorld
plugin class has been created in the very same directory as indicated by the
Plugin Builder
We are almost there so what’s next
11. Click on the command OSGeo4W located on the folder of
your QGIS
12. Type in cd “put the directory here to where the class
Hello World resides and type the plugin name itself”
cd
C:\Users\God\.qgis2\python\plugins\HelloWorld
Note: that we can have different usernames , so please take
note. Copy the directory to which the HelloWorld resides and type the
HelloWorld
13. Then type Make
pyrcc4 -o resources.py resources.qrc
which basically means that we already have
all the files needed for the plugin
14. Now restart QGIS on the Plugin Menu we click on Manage and Install Plugins .Now QGIS is
fetching repositories
15. Type in HelloWorld (the class name) in the Search Bar
The HelloWorld Plugin now appears on the search
We can now see the things we put just a while ago in the
right portion. The purpose and the brief description of the plugin. Check
the plugin then Click Close.
Now click on the Plugins menu again and now we
see that it is now available and installed on QGIS
16 .Now click on the Menu Item , Display Hello World Message
We can now see a basic plugin placed in the lower left
corner of the QGIS interface.
There you have it .You now have a basic plugin. So that’s it
for the first part. On the second part we will be coding using Python to
display Warning and Information Messages and we will be tweaking the user
interface of the plugin.
Notice that there are texts at the bottom. Just ignore it. It is the default text place on the plugin, we will remove it on the next part of the tutorial


















Comments
Post a Comment