12

I am really amazed what huge steps the QGIS development has taken in the last months. The new iconset, the improved Print composer and many more changes to be seen in QGIS 2.0 are really awesome!

Among many other cool improvements there is also this nifty blue task-bar, which I find very appealing. Text says: Save completed: Export to vector file finished

Is it possible to address this bar in python for scripts and plugins (for instance to show a small message after finished computations)? I am asking this question here, because i believe that many QGIS developers also visit this Q&A site.

PS: The bar is only visible in QGIS dev and only for some operations.

Chad Cooper
  • 12,714
  • 4
  • 46
  • 87
Curlew
  • 8,152
  • 5
  • 36
  • 72

1 Answers1

14

It sure is:

iface.messageBar().pushMessage("Header","MessageBody", QgsMessageBar.WARNING, 2)

the last arg is a timeout in seconds, if it's not supplied then it will stay until the user closes it.

You can even add you own control to the messagebar:

widget = iface.messageBar().createMessage("Test","Testing")
combo = QComboBox()
widget.layout().addWidget(combo)
iface.messageBar().pushWidget(widget, QgsMessageBar.WARNING)
combo.addItems("ASD")

enter image description here

http://www.qgis.org/api/classQgsMessageBar.html#a0b305c7215d75243b4237c299f0f7723

Nathan W
  • 34,706
  • 5
  • 97
  • 148
  • @Nathan i'm using QProgressBar instead of QComboBox. i'm unable to align the progressbar label in the right side, currently its showing in middle of the progressbar with % symbol. – venkat May 08 '13 at 04:30
  • @venkat that is the style of the progress bar. Have a look at Qt stylesheets on how to change that, or there might be a label property. – Nathan W May 08 '13 at 07:56
  • @Nathan i already raised the question regarding this but i didnt get any answer so far. kindly check this link.there i explained with screenshot and source code. http://stackoverflow.com/questions/16434215/how-to-align-qprogressbar-label-in-qgis-messagebar – venkat May 09 '13 at 04:05
  • @venkat answered over there for you – Nathan W May 09 '13 at 07:18