Class: QgsAction

Utility class that encapsulates an action based on vector attributes.

Enums

ActionType

alias of AttributeActionType

Methods

actionScopes

The action scopes define where an action will be available.

capture

Whether to capture output for display when this action is run

command

Returns the command that is executed by this action.

expressionContextScope

Returns an expression context scope used for running the action.

html

Returns an HTML table with the basic information about this action.

icon

The icon

iconPath

The path to the icon

id

Returns a unique id for this action.

isEnabledOnlyWhenEditable

Returns whether only enabled in editable mode

isValid

Returns True if this action was a default constructed one.

name

The name of the action.

notificationMessage

Returns the notification message that triggers the action

readXml

Reads an XML definition from actionNode into this object.

run

Run this action.

runable

Checks if the action is runable on the current platform

setActionScopes

The action scopes define where an action will be available.

setCommand

Sets the action command.

setEnabledOnlyWhenEditable

Set whether the action is only enabled in editable mode

setExpressionContextScope

Sets an expression context scope to use for running the action.

shortTitle

The short title is used to label user interface elements like buttons

type

The action type

writeXml

Appends an XML definition for this action as a new child node to actionsNode.

class qgis.core.QgsAction[source]

Bases: object

__init__()
__init__(type: Qgis.AttributeActionType, description: str | None, command: str | None, capture: bool = False)

Create a new QgsAction

Parameters:
  • type (Qgis.AttributeActionType) – The type of this action

  • description (Optional[str]) – A human readable description string

  • command (Optional[str]) – The action text. Its interpretation depends on the type

  • capture (bool = False) – If this is set to True, the output will be captured when an action is run

__init__(type: Qgis.AttributeActionType, description: str | None, action: str | None, icon: str | None, capture: bool, shortTitle: str | None = '', actionScopes: Iterable[str | None] = set(), notificationMessage: str | None = '')

Create a new QgsAction

Parameters:
  • type (Qgis.AttributeActionType) – The type of this action

  • description (Optional[str]) – A human readable description string

  • action (Optional[str]) – The action text. Its interpretation depends on the type

  • icon (Optional[str]) – Path to an icon for this action

  • capture (bool) – If this is set to True, the output will be captured when an action is run

  • shortTitle (Optional[str] = '') – A short string used to label user interface elements like buttons

  • actionScopes (Iterable[Optional[str]] = set()) – A set of scopes in which this action will be available

  • notificationMessage (Optional[str] = '') – A particular message which reception will trigger the action

__init__(id: QUuid, type: Qgis.AttributeActionType, description: str | None, action: str | None, icon: str | None, capture: bool, shortTitle: str | None = '', actionScopes: Iterable[str | None] = set(), notificationMessage: str | None = '')

Create a new QgsAction

Parameters:
  • id (QUuid) – The unique identifier of this action

  • type (Qgis.AttributeActionType) – The type of this action

  • description (Optional[str]) – A human readable description string

  • action (Optional[str]) – The action text. Its interpretation depends on the type

  • icon (Optional[str]) – Path to an icon for this action

  • capture (bool) – If this is set to True, the output will be captured when an action is run

  • shortTitle (Optional[str] = '') – A short string used to label user interface elements like buttons

  • actionScopes (Iterable[Optional[str]] = set()) – A set of scopes in which this action will be available

  • notificationMessage (Optional[str] = '') – A particular message which reception will trigger the action

__init__(a0: QgsAction)
Parameters:

a0 (QgsAction)

ActionType

alias of AttributeActionType

actionScopes(self) Set[str]

The action scopes define where an action will be available. Action scopes may offer additional variables like the clicked coordinate.

See also

QgsActionScope

Return type:

Set[str]

capture(self) bool[source]

Whether to capture output for display when this action is run

Return type:

bool

command(self) str[source]

Returns the command that is executed by this action. How the content is interpreted depends on the type() and the actionScope().

Return type:

str

expressionContextScope(self) QgsExpressionContextScope[source]

Returns an expression context scope used for running the action.

Return type:

QgsExpressionContextScope

html(self) str[source]

Returns an HTML table with the basic information about this action.

Added in version 3.24.

Return type:

str

icon(self) QIcon[source]

The icon

Return type:

QIcon

iconPath(self) str[source]

The path to the icon

Return type:

str

id(self) QUuid[source]

Returns a unique id for this action.

Return type:

QUuid

isEnabledOnlyWhenEditable(self) bool[source]

Returns whether only enabled in editable mode

Return type:

bool

isValid(self) bool[source]

Returns True if this action was a default constructed one.

Return type:

bool

name(self) str[source]

The name of the action. This may be a longer description.

Return type:

str

notificationMessage(self) str[source]

Returns the notification message that triggers the action

Return type:

str

readXml(self, actionNode: QDomNode)[source]

Reads an XML definition from actionNode into this object.

Parameters:

actionNode (QDomNode)

run(self, layer: QgsVectorLayer | None, feature: QgsFeature, expressionContext: QgsExpressionContext)[source]

Run this action.

Parameters:
run(self, expressionContext: QgsExpressionContext)[source]

Run this action.

Parameters:

expressionContext (QgsExpressionContext)

runable(self) bool[source]

Checks if the action is runable on the current platform

Return type:

bool

setActionScopes(self, actionScopes: Iterable[str | None])[source]

The action scopes define where an action will be available. Action scopes may offer additional variables like the clicked coordinate.

Parameters:

actionScopes (Iterable[Optional[str]])

setCommand(self, newCommand: str | None)[source]

Sets the action command.

Added in version 3.26.

Parameters:

newCommand (Optional[str])

setEnabledOnlyWhenEditable(self, enable: bool)[source]

Set whether the action is only enabled in editable mode

Added in version 3.16.

Parameters:

enable (bool)

setExpressionContextScope(self, scope: QgsExpressionContextScope)[source]

Sets an expression context scope to use for running the action.

Parameters:

scope (QgsExpressionContextScope)

shortTitle(self) str[source]

The short title is used to label user interface elements like buttons

Return type:

str

type(self) Qgis.AttributeActionType[source]

The action type

Return type:

Qgis.AttributeActionType

writeXml(self, actionsNode: QDomNode)[source]

Appends an XML definition for this action as a new child node to actionsNode.

Parameters:

actionsNode (QDomNode)