[Qgis-developer] How to use setStyle in QgsComposerScaleBar Class
Marco Hugentobler
marco.hugentobler at sourcepole.ch
Tue Jan 11 09:14:50 EST 2011
Hi Michael
> Am I doing something wrong or is this a bug?
It is a bug. However, as a short time workaround, I think it works if you use
'setStyle' after 'addComposerScaleBar':
item = QgsComposerScaleBar(composition)
composerView.addComposerScaleBar(item)
item.setItemPosition(margin_left+offset_x, margin_top+offset_y)
item.setStyle('Numeric')
item.update()
Regards,
Marco
Am Dienstag, 11. Januar 2011, um 12.02:35 schrieb Michael Pfeiffer:
> Hi everybody,
>
> I'm working on a Python PlugIn which creates a map composition.
> In the map composition I want to implement a scalebar item in numeric
> style. I try to implement the scalebar item with the following code
>
>
> item = QgsComposerScaleBar(composition)
> item.setStyle('Numeric')
> item.setItemPosition(margin_left+offset_x, margin_top+offset_y)
> composerView.addComposerScaleBar(item)
>
>
> With this code I get a scalebar item in the print composer but it's in
> single Box style.
> It doesn't matter what kind of style I select in setStyle.
> It's everytime single Box style.
> No error messages.
>
>
> print item.style()
>
>
> prints the correct style.
> Am I doing something wrong or is this a bug?
>
> Thx in advance for your answers
--
Dr. Marco Hugentobler
Sourcepole - Linux & Open Source Solutions
Churerstrasse 22, CH-8808 Pfäffikon SZ, Switzerland
marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee
More information about the Qgis-developer
mailing list