[Qgis-developer] Adding labels

Benoît Laurent blaurent at heurisis.eu
Mon May 13 08:07:18 PDT 2013


Hello,

I am not sure to be on the right place to ask my question. If not, I beg 
your pardon.

I am trying the write a Python script that :
- load a set of shapefile ;
- automatically add labels based on a field ;
- set the color, the size, etc. of my points.

For the moment, I can load the shapefiles. I also succeded in labeling 
but I am not able to move the labels manually once created. Here is my 
piece of code for labeling :
         def add_label(self, layer):
                 layer.enableLabels(1)
                 myLabel = layer.label()
                 myLabel.setLabelField( QgsLabel.Text, 17)
                 myLabel.layerAttributes().setAlignment(4)

Is there an other way of doing this ? Is there samples of code ?

Thank you in advance.

Benoît



More information about the Qgis-developer mailing list