First, there are several tutorials on the web but I would start with this one. To start, in QGIS navigate to the "Plugins" tab and download the Plugin Builder, if you don't have it installed already. The plugin builder creates a template with important information for your plugin as well as the needed files. Click on any of the screenshots to magnify them.
|QGIS Plugin Builder 2.0.3|
The next step is to compile the plugin files. This was the first hurdle. Eventually, I found a post with a solution. Double-click the OSGeo4W icon on your desktop.
- At the command prompt, point to the folder where your plugin is located. Example: cd: C:/Users/yourusername/.qgis2/python/plugins/pluginname (in this example CalculateArea is the name of the plugin). You will need to substitute the fields highlighted in red.
|Point to the directory where you plugin is located.|
- Next, type: pyuic4 -o ui_pluginname.py ui_pluginname.ui and press Enter
- Lastly, pyrcc4 -o resources.py resources.qrc and press Enter
|Compiling the Resource and UI files|
Then follow the steps for deploying and testing. After installing the plugin from the plugin tab, you should be able to see it in the tab along with any other plugins you have installed. Click it and the basic plugin window will appear! You should be able to install your plugin in QGIS and see its name.
Lastly, time to start writing some python. You can download a viewer/editor like gedit. Open up the file named pluginname.py and you will see a lot of the basic skeleton coding already written.
A few parting thoughts: Be sure to search the QGIS repositories to see if someone has already created a plugin for what you are thinking of doing. Borrow code from other plugins, which have been validated, to help speed the process along.
|The basic plugin window with the name of your plugin|
|Viewing and editing python code from the QGIS Plugin Builder|