Re: [QGIS-Developer] pyqgis labelling settings

2022-11-10 Thread Francisco Puga via QGIS-Developer
You can try

iface.layerTreeView().refreshLayerSymbology(layer.id())

El mié, 9 nov 2022 a las 18:53, Hugh Kelley () escribió:

> I finally found time to try this and it worked very well. Thank you!
>
> one follow up question I have is that I can make the change visible by
> running layer.triggerRepaint().
>
> That does not refresh the values in the layer styling panel. I need select
> a different layer and then select the original in order to see the changes
> I've made in pyqgis. Is there a command that will refresh that pane?
>
>
>
> On Sun, Oct 23, 2022 at 5:11 AM Francisco Puga  wrote:
>
>> This should work when working with SingleLabels
>>
>> layer = iface.activeLayer()
>> settings = layer.labeling().settings()
>> textFormat = settings.format()
>> textFormat.setSize(20);
>> settings.setFormat(textFormat)
>> layer.labeling().setSettings(settings)
>>
>> hope it helps
>>
>> El vie, 21 oct 2022 a las 18:18, Hugh Kelley via QGIS-Developer
>> () escribió:
>> >
>> > Hi,
>> >
>> > I'm hoping to make some scripts for labelling layers.
>> >
>> > I've found the basic labelling settings in
>> >
>> > layer =
>> iface.activeLayer()layer.labeling().settings().format().size()
>> >
>> > for example, and it seems that I could be able to update that with an
>> object like
>> >
>> > newsize = QgsTextFormat()
>> > newsize.setSize(20)
>> > but I haven't yet found the correct way to update the layer's value.
>> >
>> > it seems like it needs to be passed an entire new `QgsPalLayerSettings`
>> object but I haven't found a way to build a complete object.
>> >
>> > I've seen `readFromLayer()` but I'm guessing that was a version 2
>> method that's no longer available in version 3.
>> >
>> > any pointers or a simple piece of code for updating a layer labelling
>> property would be hugely appreciated.
>> >
>> > it also occurs to me to ask whether there is anything like:
>> >
>> > print(layer.renderer().symbol().symbolLayers()[0].properties())
>> >
>> > that returns a dict of the layer symbology properties for a label.
>> >
>> > Another helpful thing would be code that imports a label definition
>> from an exported xml file.
>> >
>> > thanks,
>> >
>> > hugh
>> >
>> > ___
>> > QGIS-Developer mailing list
>> > QGIS-Developer@lists.osgeo.org
>> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>>
>> --
>> Francisco Puga
>> iCarto | Innovación, Cooperación, Cartografía y Territorio S.L.
>> https://icarto.es
>>
>> c/ Rafael Alberti nº 13 – 1º D
>> 15008 A Coruña
>> Galicia (Spain)
>> +34 881927808
>>
>> Este correo electrónico contiene información estrictamente
>> confidencial y es de uso exclusivo del destinatario, quedando
>> prohibida a cualquier otra persona su revelación, copia, distribución,
>> o el ejercicio de cualquier acción relativa a su contenido. Si ha
>> recibido este mensaje por error, por favor conteste a su remitente
>> mediante correo electrónico y proceda a borrarlo de su sistema.
>>
>> Sus datos personales serán tratados de forma confidencial y no serán
>> cedidos a terceros ajenos a ICARTO. En cualquier caso, podrá ejercer
>> los derecho de oposición, acceso, rectificación y cancelación de
>> acuerdo con lo establecido en la Ley Orgánica 15/99, de 13 de
>> diciembre, de Protección de Datos de Carácter Personal dirigiéndose a
>> Innovación, Cooperación, Cartografía e Territorio, SL. (ICARTO) en la
>> dirección postal a C/ Rafael Alberti, nº 13, 1ºD, 15.008 – (A Coruña).
>>
>
>
> --
> Hugh Kelley
>
>

-- 
Francisco Puga
iCarto | Innovación, Cooperación, Cartografía y Territorio S.L.
https://icarto.es

c/ Rafael Alberti nº 13 – 1º D
15008 A Coruña
Galicia (Spain)
+34 881927808

Este correo electrónico contiene información estrictamente confidencial y
es de uso exclusivo del destinatario, quedando prohibida a cualquier otra
persona su revelación, copia, distribución, o el ejercicio de cualquier
acción relativa a su contenido. Si ha recibido este mensaje por error, por
favor conteste a su remitente mediante correo electrónico y proceda a
borrarlo de su sistema.

Sus datos personales serán tratados de forma confidencial y no serán
cedidos a terceros ajenos a ICARTO. En cualquier caso, podrá ejercer los
derecho de oposición, acceso, rectificación y cancelación de acuerdo con lo
establecido en la Ley Orgánica 15/99, de 13 de diciembre, de Protección de
Datos de Carácter Personal dirigiéndose a Innovación, Cooperación,
Cartografía e Territorio, SL. (ICARTO) en la dirección postal a C/ Rafael
Alberti, nº 13, 1ºD, 15.008 – (A Coruña).
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] pyqgis labelling settings

2022-11-09 Thread Hugh Kelley via QGIS-Developer
I finally found time to try this and it worked very well. Thank you!

one follow up question I have is that I can make the change visible by
running layer.triggerRepaint().

That does not refresh the values in the layer styling panel. I need select
a different layer and then select the original in order to see the changes
I've made in pyqgis. Is there a command that will refresh that pane?



On Sun, Oct 23, 2022 at 5:11 AM Francisco Puga  wrote:

> This should work when working with SingleLabels
>
> layer = iface.activeLayer()
> settings = layer.labeling().settings()
> textFormat = settings.format()
> textFormat.setSize(20);
> settings.setFormat(textFormat)
> layer.labeling().setSettings(settings)
>
> hope it helps
>
> El vie, 21 oct 2022 a las 18:18, Hugh Kelley via QGIS-Developer
> () escribió:
> >
> > Hi,
> >
> > I'm hoping to make some scripts for labelling layers.
> >
> > I've found the basic labelling settings in
> >
> > layer =
> iface.activeLayer()layer.labeling().settings().format().size()
> >
> > for example, and it seems that I could be able to update that with an
> object like
> >
> > newsize = QgsTextFormat()
> > newsize.setSize(20)
> > but I haven't yet found the correct way to update the layer's value.
> >
> > it seems like it needs to be passed an entire new `QgsPalLayerSettings`
> object but I haven't found a way to build a complete object.
> >
> > I've seen `readFromLayer()` but I'm guessing that was a version 2 method
> that's no longer available in version 3.
> >
> > any pointers or a simple piece of code for updating a layer labelling
> property would be hugely appreciated.
> >
> > it also occurs to me to ask whether there is anything like:
> >
> > print(layer.renderer().symbol().symbolLayers()[0].properties())
> >
> > that returns a dict of the layer symbology properties for a label.
> >
> > Another helpful thing would be code that imports a label definition from
> an exported xml file.
> >
> > thanks,
> >
> > hugh
> >
> > ___
> > QGIS-Developer mailing list
> > QGIS-Developer@lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> --
> Francisco Puga
> iCarto | Innovación, Cooperación, Cartografía y Territorio S.L.
> https://icarto.es
>
> c/ Rafael Alberti nº 13 – 1º D
> 15008 A Coruña
> Galicia (Spain)
> +34 881927808
>
> Este correo electrónico contiene información estrictamente
> confidencial y es de uso exclusivo del destinatario, quedando
> prohibida a cualquier otra persona su revelación, copia, distribución,
> o el ejercicio de cualquier acción relativa a su contenido. Si ha
> recibido este mensaje por error, por favor conteste a su remitente
> mediante correo electrónico y proceda a borrarlo de su sistema.
>
> Sus datos personales serán tratados de forma confidencial y no serán
> cedidos a terceros ajenos a ICARTO. En cualquier caso, podrá ejercer
> los derecho de oposición, acceso, rectificación y cancelación de
> acuerdo con lo establecido en la Ley Orgánica 15/99, de 13 de
> diciembre, de Protección de Datos de Carácter Personal dirigiéndose a
> Innovación, Cooperación, Cartografía e Territorio, SL. (ICARTO) en la
> dirección postal a C/ Rafael Alberti, nº 13, 1ºD, 15.008 – (A Coruña).
>


-- 
Hugh Kelley
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] pyqgis labelling settings

2022-10-23 Thread Francisco Puga via QGIS-Developer
This should work when working with SingleLabels

layer = iface.activeLayer()
settings = layer.labeling().settings()
textFormat = settings.format()
textFormat.setSize(20);
settings.setFormat(textFormat)
layer.labeling().setSettings(settings)

hope it helps

El vie, 21 oct 2022 a las 18:18, Hugh Kelley via QGIS-Developer
() escribió:
>
> Hi,
>
> I'm hoping to make some scripts for labelling layers.
>
> I've found the basic labelling settings in
>
> layer = iface.activeLayer()layer.labeling().settings().format().size()
>
> for example, and it seems that I could be able to update that with an object 
> like
>
> newsize = QgsTextFormat()
> newsize.setSize(20)
> but I haven't yet found the correct way to update the layer's value.
>
> it seems like it needs to be passed an entire new `QgsPalLayerSettings` 
> object but I haven't found a way to build a complete object.
>
> I've seen `readFromLayer()` but I'm guessing that was a version 2 method 
> that's no longer available in version 3.
>
> any pointers or a simple piece of code for updating a layer labelling 
> property would be hugely appreciated.
>
> it also occurs to me to ask whether there is anything like:
>
> print(layer.renderer().symbol().symbolLayers()[0].properties())
>
> that returns a dict of the layer symbology properties for a label.
>
> Another helpful thing would be code that imports a label definition from an 
> exported xml file.
>
> thanks,
>
> hugh
>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Francisco Puga
iCarto | Innovación, Cooperación, Cartografía y Territorio S.L.
https://icarto.es

c/ Rafael Alberti nº 13 – 1º D
15008 A Coruña
Galicia (Spain)
+34 881927808

Este correo electrónico contiene información estrictamente
confidencial y es de uso exclusivo del destinatario, quedando
prohibida a cualquier otra persona su revelación, copia, distribución,
o el ejercicio de cualquier acción relativa a su contenido. Si ha
recibido este mensaje por error, por favor conteste a su remitente
mediante correo electrónico y proceda a borrarlo de su sistema.

Sus datos personales serán tratados de forma confidencial y no serán
cedidos a terceros ajenos a ICARTO. En cualquier caso, podrá ejercer
los derecho de oposición, acceso, rectificación y cancelación de
acuerdo con lo establecido en la Ley Orgánica 15/99, de 13 de
diciembre, de Protección de Datos de Carácter Personal dirigiéndose a
Innovación, Cooperación, Cartografía e Territorio, SL. (ICARTO) en la
dirección postal a C/ Rafael Alberti, nº 13, 1ºD, 15.008 – (A Coruña).
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


[QGIS-Developer] pyqgis labelling settings

2022-10-21 Thread Hugh Kelley via QGIS-Developer
Hi,

I'm hoping to make some scripts for labelling layers.

I've found the basic labelling settings in

layer = iface.activeLayer()layer.labeling().settings().format().size()

for example, and it seems that I could be able to update that with an
object like

newsize = QgsTextFormat()
newsize.setSize(20)
but I haven't yet found the correct way to update the layer's value.

it seems like it needs to be passed an entire new `QgsPalLayerSettings`
object but I haven't found a way to build a complete object.

I've seen `readFromLayer()` but I'm guessing that was a version 2 method
that's no longer available in version 3.

any pointers or a simple piece of code for updating a layer labelling
property would be hugely appreciated.

it also occurs to me to ask whether there is anything like:

print(layer.renderer().symbol().symbolLayers()[0].properties())

that returns a dict of the layer symbology properties for a label.

Another helpful thing would be code that imports a label definition from an
exported xml file.

thanks,

hugh
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer