Book Image

QGIS By Example

By : Alexander Bruy, Daria Svidzinska
Book Image

QGIS By Example

By: Alexander Bruy, Daria Svidzinska

Overview of this book

Table of Contents (17 chapters)
QGIS By Example
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using Designer UI files in the plugin


Designing the GUI with the Qt Designer is the first part of the process. Now we need to use the previously created .ui files to construct our dialogs and implement the logic required for handling user actions, such as clicking on buttons, selecting items from lists, and so on.

Adding the About dialog to the plugin

We will start from the About dialog, as it is simple. To keep the plugin directory structure clean, we will store all the sources related to the plugin GUI in the gui subdirectory inside the plugin directory.

Open your text editor and create a new file with the following content:

( 1) import os
( 2) import ConfigParser
( 3)
( 4) from PyQt4 import uic
( 5) from PyQt4.QtCore import QUrl
( 6) from PyQt4.QtGui import QTextDocument, QDialogButtonBox, QPixmap
( 7)
( 8) pluginPath = os.path.split(os.path.dirname(__file__))[0]
( 9) WIDGET, BASE = uic.loadUiType(
(10)    os.path.join(pluginPath, 'ui', 'aboutdialogbase.ui'))
(11)
(12)
(13) class AboutDialog...