Class: QgsActionScope

An action scope defines a “place” for an action to be shown and may add additional expression variables.

Each QgsAction can be available in one or several action scopes.

Examples

Canvas

Show for canvas tools. Adds @click_x and @click_y in map coordinates.

Feature

Show in feature specific places like the attribute table or feature form.

Field

Show in context menus for individual fields (e.g. attribute table). Adds @field_index, @field_name and @field_value.

Layer

Show in attribute table and work on the layer or selection.

Methods

description

Returns the action scope's description.

expressionContextScope

Returns the expression context scope for the action scope.

id

Returns the unique identifier for this action scope.

isValid

Returns True if this scope is valid.

setDescription

Sets the action scope's description.

setExpressionContextScope

Sets the expression context scope for the action scope.

setId

Sets the unique id for this action scope.

setTitle

Sets the action scope's title.

title

Returns the action scope's title.

class qgis.core.QgsActionScope[source]

Bases: object

__init__()

Creates a new invalid action scope.

__init__(id: str | None, title: str | None, description: str | None, expressionContextScope: QgsExpressionContextScope = QgsExpressionContextScope())

Creates a new action scope. For details concerning the parameters check the documentation of the corresponding properties.

Parameters:
  • id (Optional[str])

  • title (Optional[str])

  • description (Optional[str])

  • expressionContextScope (QgsExpressionContextScope = QgsExpressionContextScope())

__init__(a0: QgsActionScope)
Parameters:

a0 (QgsActionScope)

description(self) str[source]

Returns the action scope’s description.

The description should be a longer description of where actions in this scope are available. It is not necessary to list the available expression variables in here, they are extracted automatically from the expressionContextScope().

See also

setDescription()

Return type:

str

expressionContextScope(self) QgsExpressionContextScope[source]

Returns the expression context scope for the action scope.

An expression scope may offer additional variables for an action scope. This can be an field_name for the attribute which was clicked or click_x and click_y for actions which are available as map canvas clicks.

Return type:

QgsExpressionContextScope

id(self) str[source]

Returns the unique identifier for this action scope.

See also

setId()

Return type:

str

isValid(self) bool[source]

Returns True if this scope is valid.

Return type:

bool

setDescription(self, description: str | None)[source]

Sets the action scope’s description.

The description should be a longer description of where actions in this scope are available. It is not necessary to list the available expression variables in here, they are extracted automatically from the expressionContextScope().

See also

description()

Parameters:

description (Optional[str])

setExpressionContextScope(self, expressionContextScope: QgsExpressionContextScope)[source]

Sets the expression context scope for the action scope.

An expression scope may offer additional variables for an action scope. This can be an field_name for the attribute which was clicked or click_x and click_y for actions which are available as map canvas clicks.

Parameters:

expressionContextScope (QgsExpressionContextScope)

setId(self, id: str | None)[source]

Sets the unique id for this action scope.

See also

id()

Parameters:

id (Optional[str])

setTitle(self, title: str | None)[source]

Sets the action scope’s title.

The title should be a human readable and translated string that will be presented to the user in the properties dialog.

See also

title()

Parameters:

title (Optional[str])

title(self) str[source]

Returns the action scope’s title.

The title is a human readable and translated string that will be presented to the user in the properties dialog.

See also

setTitle()

Return type:

str