0

I would just like to add a black border of 1mm to my legend generated with PYQgis.

Like this (with QGis): enter image description here

How can I do ?

Here is my code :

# LEGENDE
legend = QgsLayoutItemLegend(layout)

# STYLE LEGENDE (https://qgis.org/pyqgis/3.10/core/QgsLegendStyle.html)
legend.setStyleFont(QgsLegendStyle.Title, QFont('Lucida Fax', 18))
legend.setStyleFont(QgsLegendStyle.Subgroup, QFont('Lucida Fax', 13, QFont.Bold))
legend.setStyleFont(QgsLegendStyle.SymbolLabel, QFont('Lucida Fax', 11))

Thank you

1 Answers1

2
  • Use legend.setFrameEnabled(True) to activate the border
  • legend.setFrameStrokeColor(QColor('black')) to set the color
  • legend.setFrameStrokeWidth(QgsLayoutMeasurement(10, QgsUnitTypes.LayoutMillimeters)) to specify width of the border

API Documentation

CodeBard
  • 256
  • 2
  • 4