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 (<qgis-developer@lists.osgeo.org>) 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