Subgroup: Text
Class: QgsTextBackgroundSettings¶
-
class
qgis.core.
QgsTextBackgroundSettings
¶ Bases:
sip.wrapper
Container for settings relating to a text background object.
Note
QgsTextBackgroundSettings objects are implicitly shared.
New in version 3.0: Methods
blendMode
Returns the blending mode used for drawing the background shape. enabled
Returns whether the background is enabled. fillColor
Returns the color used for filing the background shape. joinStyle
Returns the join style used for drawing the background shape. offset
Returns the offset used for drawing the background shape. offsetMapUnitScale
Returns the map unit scale object for the shape offset. offsetUnit
Returns the units used for the shape’s offset. opacity
Returns the background shape’s opacity. paintEffect
Returns the current paint effect for the background shape. radii
Returns the radii used for rounding the corners of shapes. radiiMapUnitScale
Returns the map unit scale object for the shape radii. radiiUnit
Returns the units used for the shape’s radii. readFromLayer
Reads settings from a layer’s custom properties (for QGIS 2.x projects). readXml
Read settings from a DOM element. rotation
Returns the rotation for the background shape, in degrees clockwise. rotationType
Returns the method used for rotating the background shape. setBlendMode
Sets the blending mode used for drawing the background shape. setEnabled
Sets whether the text background will be drawn. setFillColor
Sets the color used for filing the background shape. setJoinStyle
Sets the join style used for drawing the background shape. setOffset
Sets the offset used for drawing the background shape. setOffsetMapUnitScale
Sets the map unit scale object for the shape offset. setOffsetUnit
Sets the units used for the shape’s offset. setOpacity
Sets the background shape’s opacity. setPaintEffect
Sets the current paint effect
for the background shape.setRadii
Sets the radii used for rounding the corners of shapes. setRadiiMapUnitScale
Sets the map unit scale object for the shape radii. setRadiiUnit
Sets the units used for the shape’s radii. setRotation
Sets the rotation
for the background shape, in degrees clockwise.setRotationType
Sets the method used for rotating the background shape. setSize
Sets the size of the background shape. setSizeMapUnitScale
Sets the map unit scale object for the shape size. setSizeType
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around text). setSizeUnit
Sets the units used for the shape’s size. setStrokeColor
Sets the color used for outlining the background shape. setStrokeWidth
Sets the width of the shape’s stroke (stroke). setStrokeWidthMapUnitScale
Sets the map unit scale object for the shape stroke width. setStrokeWidthUnit
Sets the units used for the shape’s stroke width. setSvgFile
Sets the path to the background SVG file. setType
Sets the type of background shape to draw (e.g., square, ellipse, SVG). size
Returns the size of the background shape. sizeMapUnitScale
Returns the map unit scale object for the shape size. sizeType
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer around text). sizeUnit
Returns the units used for the shape’s size. strokeColor
Returns the color used for outlining the background shape. strokeWidth
Returns the width of the shape’s stroke (stroke). strokeWidthMapUnitScale
Returns the map unit scale object for the shape stroke width. strokeWidthUnit
Returns the units used for the shape’s stroke width. svgFile
Returns the absolute path to the background SVG file, if set. type
Returns the type of background shape (e.g., square, ellipse, SVG). writeXml
Write settings into a DOM element. Attributes
RotationFixed
RotationOffset
RotationSync
ShapeCircle
ShapeEllipse
ShapeRectangle
ShapeSVG
ShapeSquare
SizeBuffer
SizeFixed
SizePercent
-
RotationFixed
= 2¶
-
RotationOffset
= 1¶
-
RotationSync
= 0¶
-
class
RotationType
¶ Bases:
int
-
ShapeCircle
= 3¶
-
ShapeEllipse
= 2¶
-
ShapeRectangle
= 0¶
-
ShapeSVG
= 4¶
-
ShapeSquare
= 1¶
-
class
ShapeType
¶ Bases:
int
-
SizeBuffer
= 0¶
-
SizeFixed
= 1¶
-
SizePercent
= 2¶
-
class
SizeType
¶ Bases:
int
-
blendMode
(self) → QPainter.CompositionMode¶ Returns the blending mode used for drawing the background shape.
See also
-
enabled
(self) → bool¶ Returns whether the background is enabled.
See also
-
fillColor
(self) → QColor¶ Returns the color used for filing the background shape.
See also
See also
-
joinStyle
(self) → Qt.PenJoinStyle¶ Returns the join style used for drawing the background shape.
See also
-
offset
(self) → QPointF¶ Returns the offset used for drawing the background shape. Units are determined via offsetUnit().
See also
See also
-
offsetMapUnitScale
(self) → QgsMapUnitScale¶ Returns the map unit scale object for the shape offset. This is only used if the offsetUnit() is set to QgsUnitTypes.RenderMapUnit.
See also
See also
-
offsetUnit
(self) → QgsUnitTypes.RenderUnit¶ Returns the units used for the shape’s offset.
See also
See also
-
opacity
(self) → float¶ Returns the background shape’s opacity. The opacity is a double value between 0 (fully transparent) and 1 (totally opaque).
See also
-
paintEffect
(self) → QgsPaintEffect¶ Returns the current paint effect for the background shape.
Returns: paint effect See also
-
radii
(self) → QSizeF¶ Returns the radii used for rounding the corners of shapes. Units are retrieved through radiiUnit().
See also
See also
-
radiiMapUnitScale
(self) → QgsMapUnitScale¶ Returns the map unit scale object for the shape radii. This is only used if the radiiUnit() is set to QgsUnitTypes.RenderMapUnit.
See also
See also
-
radiiUnit
(self) → QgsUnitTypes.RenderUnit¶ Returns the units used for the shape’s radii.
See also
See also
-
readFromLayer
(self, layer: QgsVectorLayer)¶ Reads settings from a layer’s custom properties (for QGIS 2.x projects).
Parameters: layer – source vector layer
-
readXml
(self, elem: QDomElement, context: QgsReadWriteContext)¶ Read settings from a DOM element.
See also
-
rotation
(self) → float¶ Returns the rotation for the background shape, in degrees clockwise.
See also
See also
-
rotationType
(self) → QgsTextBackgroundSettings.RotationType¶ Returns the method used for rotating the background shape.
See also
See also
-
setBlendMode
(self, mode: QPainter.CompositionMode)¶ Sets the blending mode used for drawing the background shape.
Parameters: mode – blending mode See also
-
setEnabled
(self, enabled: bool)¶ Sets whether the text background will be drawn.
Parameters: enabled – set to true to draw background See also
-
setFillColor
(self, color: Union[QColor, Qt.GlobalColor, QGradient])¶ Sets the color used for filing the background shape.
Parameters: color – background color See also
See also
-
setJoinStyle
(self, style: Qt.PenJoinStyle)¶ Sets the join style used for drawing the background shape.
Parameters: style – join style See also
-
setOffset
(self, offset: Union[QPointF, QPoint])¶ Sets the offset used for drawing the background shape. Units are specified using setOffsetUnit().
Parameters: offset – offset for shape See also
See also
-
setOffsetMapUnitScale
(self, scale: QgsMapUnitScale)¶ Sets the map unit scale object for the shape offset. This is only used if the offsetUnit() is set to QgsUnitTypes.RenderMapUnit.
Parameters: scale – scale for shape offset See also
See also
-
setOffsetUnit
(self, units: QgsUnitTypes.RenderUnit)¶ Sets the units used for the shape’s offset.
Parameters: units – offset units See also
See also
-
setOpacity
(self, opacity: float)¶ Sets the background shape’s opacity.
Parameters: opacity – opacity as a double value between 0 (fully transparent) and 1 (totally opaque)
See also
-
setPaintEffect
(self, effect: QgsPaintEffect)¶ Sets the current paint
effect
for the background shape.Parameters: effect – paint effect. Ownership is transferred to the background settings. See also
-
setRadii
(self, radii: QSizeF)¶ Sets the radii used for rounding the corners of shapes. This is only used if type() is set to QgsTextBackgroundSettings.ShapeRectangle or QgsTextBackgroundSettings.ShapeSquare.
Parameters: radii – QSizeF representing horizontal and vertical radii for rounded corners. Units are specified through setRadiiUnit()
See also
See also
-
setRadiiMapUnitScale
(self, scale: QgsMapUnitScale)¶ Sets the map unit scale object for the shape radii. This is only used if the radiiUnit() is set to QgsUnitTypes.RenderMapUnit.
Parameters: scale – scale for shape radii See also
See also
-
setRadiiUnit
(self, units: QgsUnitTypes.RenderUnit)¶ Sets the units used for the shape’s radii.
Parameters: units – radii units See also
See also
-
setRotation
(self, rotation: float)¶ Sets the
rotation
for the background shape, in degrees clockwise.See also
See also
-
setRotationType
(self, type: QgsTextBackgroundSettings.RotationType)¶ Sets the method used for rotating the background shape.
Parameters: type – rotation method See also
See also
-
setSize
(self, size: QSizeF)¶ Sets the size of the background shape. The meaning of the size depends on the current sizeType(), e.g., for size types of QgsTextBackgroundSettings.SizeFixed the size will represent the actual width and height of the shape, for QgsTextBackgroundSettings.SizeBuffer the size will represent the horizontal and vertical margins to add to the text when calculating the size of the shape.
Parameters: size – QSizeF representing horizontal and vertical size components for shape See also
See also
-
setSizeMapUnitScale
(self, scale: QgsMapUnitScale)¶ Sets the map unit scale object for the shape size. This is only used if the sizeUnit() is set to QgsUnitTypes.RenderMapUnit.
Parameters: scale – scale for shape size See also
See also
-
setSizeType
(self, type: QgsTextBackgroundSettings.SizeType)¶ Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around text).
Parameters: type – size method See also
See also
-
setSizeUnit
(self, unit: QgsUnitTypes.RenderUnit)¶ Sets the units used for the shape’s size. This value has no meaning if the sizeType() is set to QgsTextBackgroundSettings.SizePercent.
Parameters: unit – size units See also
See also
See also
-
setStrokeColor
(self, color: Union[QColor, Qt.GlobalColor, QGradient])¶ Sets the color used for outlining the background shape.
Parameters: color – stroke color See also
See also
-
setStrokeWidth
(self, width: float)¶ Sets the width of the shape’s stroke (stroke). Units are specified through setStrokeWidthUnit().
See also
See also
-
setStrokeWidthMapUnitScale
(self, scale: QgsMapUnitScale)¶ Sets the map unit scale object for the shape stroke width. This is only used if the strokeWidthUnit() is set to QgsUnitTypes.RenderMapUnit.
Parameters: scale – scale for shape stroke width See also
See also
-
setStrokeWidthUnit
(self, units: QgsUnitTypes.RenderUnit)¶ Sets the units used for the shape’s stroke width.
Parameters: units – stroke width units See also
See also
-
setSvgFile
(self, file: str)¶ Sets the path to the background SVG file. This is only used if type() is set to QgsTextBackgroundSettings.ShapeSVG. The path must be absolute.
Parameters: file – Absolute SVG file path See also
-
setType
(self, type: QgsTextBackgroundSettings.ShapeType)¶ Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Parameters: type – shape type See also
-
size
(self) → QSizeF¶ Returns the size of the background shape. The meaning of the size depends on the current sizeType(), e.g., for size types of QgsTextBackgroundSettings.SizeFixed the size will represent the actual width and height of the shape, for QgsTextBackgroundSettings.SizeBuffer the size will represent the horizontal and vertical margins to add to the text when calculating the size of the shape.
See also
See also
-
sizeMapUnitScale
(self) → QgsMapUnitScale¶ Returns the map unit scale object for the shape size. This is only used if the sizeUnit() is set to QgsUnitTypes.RenderMapUnit.
See also
See also
-
sizeType
(self) → QgsTextBackgroundSettings.SizeType¶ Returns the method used to determine the size of the background shape (e.g., fixed size or buffer around text).
See also
See also
-
sizeUnit
(self) → QgsUnitTypes.RenderUnit¶ Returns the units used for the shape’s size. This value has no meaning if the sizeType() is set to QgsTextBackgroundSettings.SizePercent.
See also
See also
See also
-
strokeColor
(self) → QColor¶ Returns the color used for outlining the background shape.
See also
See also
-
strokeWidth
(self) → float¶ Returns the width of the shape’s stroke (stroke). Units are retrieved through strokeWidthUnit().
See also
See also
-
strokeWidthMapUnitScale
(self) → QgsMapUnitScale¶ Returns the map unit scale object for the shape stroke width. This is only used if the strokeWidthUnit() is set to QgsUnitTypes.RenderMapUnit.
See also
See also
-
strokeWidthUnit
(self) → QgsUnitTypes.RenderUnit¶ Returns the units used for the shape’s stroke width.
See also
See also
-
svgFile
(self) → str¶ Returns the absolute path to the background SVG file, if set.
See also
-
type
(self) → QgsTextBackgroundSettings.ShapeType¶ Returns the type of background shape (e.g., square, ellipse, SVG).
See also
-