Creating checkboxes

Checkboxes are closely related to radio buttons, in that they offer options around a single theme. However, unlike radio buttons, checkboxes can be selected or unselected. You can also select more than one checkbox at a time. In this recipe, we'll create a dialog with checkboxes and some textboxes to programmatically track which checkboxes are selected.

Getting ready

Open the QGIS Python console by selecting the Plugins menu and then clicking on Python Console.

How to do it...

In this recipe, we'll use a class to manage the checkboxes and the textbox widgets, as follows:

  1. First, we import the GUI and QGIS core libraries:
            from PyQt4.QtCore import * 
            from PyQt4.QtGui import * 
    
  2. Next, we create our custom class for the checkboxes and textboxes: ...

Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.