Displaying a progress bar
A progress bar is a dynamic dialog that displays the percentage of completion bar for a running process that the user must wait for before continuing. A progress bar is more advanced than a simple dialog, because it needs to be updated continuously. In this recipe, we'll create a simple progress dialog based on a timer.
Getting ready
Open the QGIS Python console by selecting the Plugins menu and then clicking on Python Console.
How to do it...
The steps for this recipe include creating a custom class based on the QProgressBar
, initializing the dialog and setting its size and title, creating a timer, connecting the progress bar to the timer, starting the time, and displaying the progress. To do this, we need to perform the following steps:
- First, we must import both the GUI and QGIS core libraries:
from PyQt4.QtGui import * from PyQt4.QtCore import *
- Next, we create a custom class for our progress bar, including a method to increase the value of...