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:

  1. First, we must import both ...

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.