Graphics Reference
In-Depth Information
Progress indicators
You can also make use of the message bar to display a Qt progress indicator. To do this, use
the messageBar.createMessage() method to create a widget to display your mes-
sage, then modify the widget to include additional Qt controls, and finally call the mes-
sageBar.pushWidget() method to display the message and the controls you added.
For example:
progressMessage = iface.messageBar().createMessage("Please
wait")
progressBar = QProgressBar()
progressBar.setMaximum(100)
progressBar.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
progressMessage.layout().addWidget(progressBar)
iface.messageBar().pushWidget(progressMessage)
...
progressBar.setValue(n)
...
iface.messageBar().clearWidgets()
Note
There is a bug in the Mac version of QGIS 2.2, which prevents the user interface from up-
dating while your Python code is running. A workaround for this is to use threads, as de-
scribed in the following article: http://snorf.net/blog/2013/12/07/multithreading-in-qgis-
python-plugins
Search WWH ::




Custom Search