A progress bar is a dynamic dialog that displays the percentage complete 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.
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 the progress bar:
class Bar(QProgressBar): value = 0 def increaseValue(self): ...