Pushing widgets to the message bar
Just like the status bar, the message bar can contain any type of widget, not just text. Although it is primarily intended for simple text messages, sometimes you may want to add items such as a progress bar to track processing. In this recipe, we'll display a progress bar in the message bar.
Getting ready
Open the QGIS Python console by selecting the Plugins menu and then clicking on Python Console.
How to do it...
First we'll build out our progress bar as we did earlier in this chapter. It will simply run on a timer. Then we'll add it to the message bar and we'll tell the message bar to stay visible for 10 seconds instead of the usual five seconds, so we can see the progress bar finish:
- 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...