Class: QgsSymbolWidgetContext

Contains settings which reflect the context in which a symbol (or renderer) widget is shown, e.g., the map canvas and relevant expression contexts.

class qgis.gui.QgsSymbolWidgetContext[source]

Bases: object

additionalExpressionContextScopes(self) List[QgsExpressionContextScope]

Returns the list of additional expression context scopes to show as available within the layer.

Return type:

List[QgsExpressionContextScope]

expressionContext(self) QgsExpressionContext | None[source]

Returns the expression context used for the widget, if set. This expression context is used for evaluating data defined symbol properties and for populating based expression widgets in the layer widget.

Return type:

Optional[QgsExpressionContext]

globalProjectAtlasMapLayerScopes(self, layer: QgsMapLayer | None) List[QgsExpressionContextScope]

Returns list of scopes: global, project, atlas, map, layer. Ownership is transferred to the caller.

Parameters:

layer (Optional[QgsMapLayer])

Return type:

List[QgsExpressionContextScope]

mapCanvas(self) QgsMapCanvas | None[source]

Returns the map canvas associated with the widget.

See also

setMapCanvas()

Return type:

Optional[QgsMapCanvas]

messageBar(self) QgsMessageBar | None[source]

Returns the message bar associated with the widget.

See also

setMessageBar()

Added in version 3.6.

Return type:

Optional[QgsMessageBar]

setAdditionalExpressionContextScopes(self, scopes: Iterable[QgsExpressionContextScope])[source]

Sets a list of additional expression context scopes to show as available within the layer.

Parameters:

scopes (Iterable[QgsExpressionContextScope]) – list of additional scopes which will be added in order to the end of the default expression context

setExpressionContext(self, context: QgsExpressionContext | None)[source]

Sets the optional expression context used for the widget. This expression context is used for evaluating data defined symbol properties and for populating based expression widgets in the layer widget.

Parameters:

context (Optional[QgsExpressionContext]) – expression context pointer. Ownership is not transferred.

setMapCanvas(self, canvas: QgsMapCanvas | None)[source]

Sets the map canvas associated with the widget. This allows the widget to retrieve the current map scale and other properties from the canvas.

Parameters:

canvas (Optional[QgsMapCanvas]) – map canvas

See also

mapCanvas()

setMessageBar(self, bar: QgsMessageBar | None)[source]

Sets the message bar associated with the widget. This allows the widget to push feedback messages to the appropriate message bar.

See also

messageBar()

Added in version 3.6.

Parameters:

bar (Optional[QgsMessageBar])

setSymbolType(self, type: Qgis.SymbolType)[source]

Sets the associated symbol type, if the widget is being shown as a subcomponent of a parent symbol configuration widget.

See also

symbolType()

Added in version 3.18.

Parameters:

type (Qgis.SymbolType)

symbolType(self) Qgis.SymbolType[source]

Returns the associated symbol type, if the widget is being shown as a subcomponent of a parent symbol configuration widget.

See also

setSymbolType()

Added in version 3.18.

Return type:

Qgis.SymbolType