Class: QgsBalloonCallout

class qgis.core.QgsBalloonCallout

Bases: QgsCallout

A cartoon talking bubble callout style.

New in version 3.20:

Methods

calloutLabelPoint

Returns the anchor point geometry for a label with the given bounding box and anchor point mode.

calloutLineToPart

Calculates the direct line from a label geometry to an anchor geometry part, respecting the various callout settings which influence how the callout end should be placed in the anchor geometry.

clone

rtype

QgsBalloonCallout

cornerRadius

Returns the corner radius of the balloon shapes.

cornerRadiusMapUnitScale

Returns the map unit scale for the corner radius.

cornerRadiusUnit

Returns the units for the corner radius.

create

Creates a new QgsBalloonCallout, using the settings serialized in the properties map (corresponding to the output from QgsBalloonCallout.properties() ).

draw

param context

fillSymbol

Returns the fill symbol used to render the callout.

labelAnchorGeometry

Returns the anchor point geometry for a label with the given bounding box and anchor point mode.

margins

Returns the margins between the outside of the callout frame and the label's bounding rectangle.

marginsUnit

Returns the units for the margins between the outside of the callout frame and the label's bounding rectangle.

offsetFromAnchor

Returns the offset distance from the anchor point at which to start the line.

offsetFromAnchorMapUnitScale

Returns the map unit scale for the offset from anchor.

offsetFromAnchorUnit

Returns the units for the offset from anchor point.

properties

param context

readProperties

param props

referencedFields

param context

setCornerRadius

Sets the radius of the corners for the balloon shapes.

setCornerRadiusMapUnitScale

Sets the map unit scale for the corner radius.

setCornerRadiusUnit

Sets the unit for the corner radius.

setFillSymbol

Sets the fill symbol used to render the callout.

setMargins

Sets the margins between the outside of the callout frame and the label's bounding rectangle.

setMarginsUnit

Sets the unit for the margins between the outside of the callout frame and the label's bounding rectangle.

setOffsetFromAnchor

Sets the offset distance from the anchor point at which to start the line.

setOffsetFromAnchorMapUnitScale

Sets the map unit scale for the offset from anchor.

setOffsetFromAnchorUnit

Sets the unit for the offset from anchor distance.

setWedgeWidth

Sets the width of the wedge shape at the side it connects with the label.

setWedgeWidthMapUnitScale

Sets the map unit scale for the wedge width.

setWedgeWidthUnit

Sets the unit for the wedge width.

startRender

param context

stopRender

param context

type

rtype

str

wedgeWidth

Returns the width of the wedge shape at the side it connects with the label.

wedgeWidthMapUnitScale

Returns the map unit scale for the wedge width.

wedgeWidthUnit

Returns the units for the wedge width.

calloutLabelPoint(self, bodyBoundingBox: QRectF, angle: float, anchor: QgsCallout.LabelAnchorPoint, context: QgsRenderContext, calloutContext: QgsCallout.QgsCalloutContext) Tuple[QgsGeometry, bool]

Returns the anchor point geometry for a label with the given bounding box and anchor point mode.

The pinned argument will be set to True if the callout label point is pinned (manually placed).

New in version 3.20.

calloutLineToPart(self, labelGeometry: QgsGeometry, partGeometry: QgsAbstractGeometry, context: QgsRenderContext, calloutContext: QgsCallout.QgsCalloutContext) Tuple[QgsGeometry, bool]

Calculates the direct line from a label geometry to an anchor geometry part, respecting the various callout settings which influence how the callout end should be placed in the anchor geometry.

Returns a null geometry if the callout line cannot be calculated.

The pinned argument will be set to True if the callout anchor point is pinned (manually placed).

New in version 3.20.

clone(self) QgsBalloonCallout
Return type

QgsBalloonCallout

cornerRadius(self) float

Returns the corner radius of the balloon shapes.

Units are specified through wedgeWidthUnit().

Return type

float

cornerRadiusMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the corner radius.

See also

cornerRadius()

Return type

QgsMapUnitScale

cornerRadiusUnit(self) QgsUnitTypes.RenderUnit

Returns the units for the corner radius.

See also

cornerRadius()

Return type

QgsUnitTypes.RenderUnit

create(properties: Dict[str, Any] = {}, context: QgsReadWriteContext = QgsReadWriteContext()) QgsCallout

Creates a new QgsBalloonCallout, using the settings serialized in the properties map (corresponding to the output from QgsBalloonCallout.properties() ).

Parameters
Return type

QgsCallout

draw(self, context: QgsRenderContext, bodyBoundingBox: QRectF, angle: float, anchor: QgsGeometry, calloutContext: QgsCallout.QgsCalloutContext)
Parameters
fillSymbol(self) QgsFillSymbol

Returns the fill symbol used to render the callout.

Ownership is not transferred.

See also

setFillSymbol()

Return type

QgsFillSymbol

labelAnchorGeometry(self, bodyBoundingBox: QRectF, angle: float, anchor: QgsCallout.LabelAnchorPoint) QgsGeometry

Returns the anchor point geometry for a label with the given bounding box and anchor point mode.

Deprecated since version QGIS: 3.20 use calloutLabelPoint() instead

margins(self) QgsMargins

Returns the margins between the outside of the callout frame and the label’s bounding rectangle.

Units are retrieved via marginsUnit()

Note

Negative margins are acceptable.

See also

setMargins()

See also

marginsUnit()

Return type

QgsMargins

marginsUnit(self) QgsUnitTypes.RenderUnit

Returns the units for the margins between the outside of the callout frame and the label’s bounding rectangle.

See also

setMarginsUnit()

See also

margins()

Return type

QgsUnitTypes.RenderUnit

offsetFromAnchor(self) float

Returns the offset distance from the anchor point at which to start the line. Units are specified through offsetFromAnchorUnit().

Return type

float

offsetFromAnchorMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the offset from anchor.

Return type

QgsMapUnitScale

offsetFromAnchorUnit(self) QgsUnitTypes.RenderUnit

Returns the units for the offset from anchor point.

Return type

QgsUnitTypes.RenderUnit

properties(self, context: QgsReadWriteContext) Dict[str, Any]
Parameters

context (QgsReadWriteContext) –

Return type

Dict[str, Any]

readProperties(self, props: Dict[str, Any], context: QgsReadWriteContext)
Parameters
referencedFields(self, context: QgsRenderContext) Set[str]
Parameters

context (QgsRenderContext) –

Return type

Set[str]

setCornerRadius(self, radius: float)

Sets the radius of the corners for the balloon shapes.

Units are specified through setCornerRadiusUnit().

See also

cornerRadius()

Parameters

radius (float) –

setCornerRadiusMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the corner radius.

Parameters

scale (QgsMapUnitScale) –

setCornerRadiusUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the corner radius.

Parameters

unit (QgsUnitTypes.RenderUnit) –

setFillSymbol(self, symbol: QgsFillSymbol)

Sets the fill symbol used to render the callout. Ownership of symbol is transferred to the callout.

See also

fillSymbol()

Parameters

symbol (QgsFillSymbol) –

setMargins(self, margins: QgsMargins)

Sets the margins between the outside of the callout frame and the label’s bounding rectangle.

Units are set via setMarginsUnit()

Note

Negative margins are acceptable.

See also

margins()

See also

setMarginsUnit()

Parameters

margins (QgsMargins) –

setMarginsUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the margins between the outside of the callout frame and the label’s bounding rectangle.

See also

margins()

See also

marginsUnit()

Parameters

unit (QgsUnitTypes.RenderUnit) –

setOffsetFromAnchor(self, distance: float)

Sets the offset distance from the anchor point at which to start the line. Units are specified through setOffsetFromAnchorUnit().

Parameters

distance (float) –

setOffsetFromAnchorMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the offset from anchor.

Parameters

scale (QgsMapUnitScale) –

setOffsetFromAnchorUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the offset from anchor distance.

Parameters

unit (QgsUnitTypes.RenderUnit) –

setWedgeWidth(self, width: float)

Sets the width of the wedge shape at the side it connects with the label.

Units are specified through setWedgeWidthUnit().

See also

wedgeWidth()

Parameters

width (float) –

setWedgeWidthMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the wedge width.

See also

setWedgeWidth()

Parameters

scale (QgsMapUnitScale) –

setWedgeWidthUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the wedge width.

See also

wedgeWidthUnit()

See also

setWedgeWidth()

Parameters

unit (QgsUnitTypes.RenderUnit) –

startRender(self, context: QgsRenderContext)
Parameters

context (QgsRenderContext) –

stopRender(self, context: QgsRenderContext)
Parameters

context (QgsRenderContext) –

type(self) str
Return type

str

wedgeWidth(self) float

Returns the width of the wedge shape at the side it connects with the label.

Units are specified through wedgeWidthUnit().

See also

setWedgeWidth()

See also

wedgeWidthUnit()

Return type

float

wedgeWidthMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the wedge width.

See also

wedgeWidthUnit()

See also

wedgeWidth()

Return type

QgsMapUnitScale

wedgeWidthUnit(self) QgsUnitTypes.RenderUnit

Returns the units for the wedge width.

See also

wedgeWidth()

Return type

QgsUnitTypes.RenderUnit