Class: QgsAction

class qgis.core.QgsAction

Bases: sip.wrapper

Utility class that encapsulates an action based on vector attributes.

QgsAction() Default constructor

QgsAction(type: QgsAction.ActionType, description: str, command: str, capture: bool = False) Create a new QgsAction

Parameters:
  • type – The type of this action

  • description – A human readable description string

  • command – The action text. Its interpretation depends on the type

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

QgsAction(type: QgsAction.ActionType, description: str, action: str, icon: str, capture: bool, shortTitle: str = ‘’, actionScopes: Iterable[str] = set(), notificationMessage: str = ‘’) Create a new QgsAction

Parameters:
  • type – The type of this action

  • description – A human readable description string

  • action – The action text. Its interpretation depends on the type

  • icon – Path to an icon for this action

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

  • shortTitle – A short string used to label user interface elements like buttons

  • actionScopes – A set of scopes in which this action will be available

  • notificationMessage – A particular message which reception will trigger the action

QgsAction(id: QUuid, type: QgsAction.ActionType, description: str, action: str, icon: str, capture: bool, shortTitle: str = ‘’, actionScopes: Iterable[str] = set(), notificationMessage: str = ‘’) Create a new QgsAction

Parameters:
  • id – The unique identifier of this action

  • type – The type of this action

  • description – A human readable description string

  • action – The action text. Its interpretation depends on the type

  • icon – Path to an icon for this action

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

  • shortTitle – A short string used to label user interface elements like buttons

  • actionScopes – A set of scopes in which this action will be available

  • notificationMessage – A particular message which reception will trigger the action

QgsAction(QgsAction)

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.

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.

Attributes

Generic

GenericPython

Mac

OpenUrl

Unix

Windows

class ActionType

Bases: int

Generic = 0
GenericPython = 1
Mac = 2
OpenUrl = 5
Unix = 4
Windows = 3
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

New in version 3.0.

Return type:

Set[str]

capture(self) bool

Whether to capture output for display when this action is run

Return type:

bool

command(self) str

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

New in version 3.0.

Return type:

str

expressionContextScope(self) QgsExpressionContextScope

Returns an expression context scope used for running the action.

New in version 3.0.

Return type:

QgsExpressionContextScope

html(self) str

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

New in version 3.24.

Return type:

str

icon(self) QIcon

The icon

Return type:

QIcon

iconPath(self) str

The path to the icon

Return type:

str

id(self) QUuid

Returns a unique id for this action.

New in version 3.0.

Return type:

QUuid

isEnabledOnlyWhenEditable(self) bool

Returns whether only enabled in editable mode

Return type:

bool

isValid(self) bool

Returns True if this action was a default constructed one.

New in version 3.0.

Return type:

bool

name(self) str

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

Return type:

str

notificationMessage(self) str

Returns the notification message that triggers the action

New in version 3.0.

Return type:

str

readXml(self, actionNode: QDomNode)

Reads an XML definition from actionNode into this object.

New in version 3.0.

Parameters:

actionNode (QDomNode) –

run(self, layer: QgsVectorLayer, feature: QgsFeature, expressionContext: QgsExpressionContext)

Run this action.

New in version 3.0.

run(self, expressionContext: QgsExpressionContext) Run this action.

New in version 3.0.

Parameters:
runable(self) bool

Checks if the action is runable on the current platform

Return type:

bool

setActionScopes(self, actionScopes: Iterable[str])

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

New in version 3.0.

Parameters:

actionScopes (Iterable[str]) –

setEnabledOnlyWhenEditable(self, enable: bool)

Set whether the action is only enabled in editable mode

New in version 3.16.

Parameters:

enable (bool) –

setExpressionContextScope(self, scope: QgsExpressionContextScope)

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

New in version 3.0.

Parameters:

scope (QgsExpressionContextScope) –

shortTitle(self) str

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

Return type:

str

type(self) QgsAction.ActionType

The action type

Return type:

QgsAction.ActionType

writeXml(self, actionsNode: QDomNode)

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

New in version 3.0.

Parameters:

actionsNode (QDomNode) –