Plugins and pyqgis

Plugins and pyqgis

To understand how to power up QGIS with Python scripting language. The aim is to provide the tools and the basic knowledge to develop Python scripts and plugins. After a quick introduction to Python the participants will be guided step by step to develop scripts and a plugin.

Knowledge of basic Python skills is useful, but not necessary. At least a basic knowledge of programming principles and of QGIS is needed.

Course outline

  • Introduction to python language in QGIS

    • the python syntax (indentation, colon, …)
    • importing external modules
  • The main QT API classes

    • QtCore module (QObject, QString, QAction, QFile, ...)
    • QtGui module (QWidget, QDialog, QMessageBox, QFileDialog, ...)
    • access Qt API through python: PyQT (Qt types mapped by python native types, out parameter)
    • signal/slot management of PyQt
  • The main QGis API classes and their relations

    • constants and settings: Qgis, QgsProject, QgsApplication classes
    • canvas, layers and legend: QgsMapCanvas, QgsMapLayer, QgsProject, QgsMapLayerRegistry, QgsLayerTree
    • vector layer: QgsVectorLayer, QgsVectorDataProvider, QgsField, QgsFeature, QgsGeometry
    • raster layer: QgsRasterLayer
    • map tools and rubber band: QgsMapTool, QgsMapToolEmitPoint
    • canvas items and snapper: QgsMapCanvas
    • CRS classes: QgsCoordinateReferenceSystem, QgsCoordinateTransform
  • Plugin creation

    • use of classes and methods to create a plugin
    • Plugin Builder and Plugin Reloader
    • create GUIs using QtDesigner (.ui)
    • metadata management for the plugin publication
    • correct method to manage the plugin
  • Use of version controlled software (git)

    • introduction to git
    • advantages of a versioning system
    • useful git commands (git add, git commit, git pull, git push)
    • branch and conflict management
    • publication of the plugin on a remote hosting (github, gitlab, ...)
    • correct management of an issue/bug tracker

Length

Three days, full time