[Qgis-developer] Python plugin: how to set a symbol for a layer?

Giuseppe Sucameli sucameli at faunalia.it
Fri Apr 1 07:15:36 EDT 2011


Hi Luca,

On Fri, Apr 1, 2011 at 9:14 AM, <luca_manganelli at comune.trento.it> wrote:

> I've searched across documentation and mailing list, but I didn't found a
> page explaining how to set a symbol.
>
create your style within QGis and save it as e.g. "point.qml" in your plugin
folder,
then load it using this snapshot:

import os.path
style_path = os.path.join( os.path.dirname(__file__), "point.qml" )
(errorMsg, result) = vectorLayer.loadNamedStyle( style_path )

So to change the style of the layer it consists just in a file replacing
without any change
in your code.

Cheers.


> For example:
>
>  - point layer: I want to use a circle with width 0.5 and gray colour with
> black border;
>  - line layer: width 1 and continous green line
>
> any hint?
>
> Thank you in advance.
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Giuseppe Sucameli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110401/5fe64c87/attachment.html


More information about the Qgis-developer mailing list