Subgroup: Action

Class: QgsAction

class qgis.core.QgsAction

Bases: sip.wrapper

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
  • enabledOnlyWhenEditable – if true then action is only enable in editmode

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
  • enabledOnlyWhenEditable – if true then action is only enable in editmode

QgsAction(QgsAction)

Utility class that encapsulates an action based on vector attributes.

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.
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.
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.

Signals

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.

capture(self) → bool

Whether to capture output for display when this action is run

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.

expressionContextScope(self) → QgsExpressionContextScope

Returns an expression context scope used for running the action.

New in version 3.0.

icon(self) → QIcon

The icon

iconPath(self) → str

The path to the icon

id(self) → QUuid

Returns a unique id for this action.

New in version 3.0.

isEnabledOnlyWhenEditable(self) → bool

Returns whether only enabled in editable mode

isValid(self) → bool

Returns true if this action was a default constructed one.

New in version 3.0.

name(self) → str

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

notificationMessage(self) → str

Returns the notification message that triggers the action

New in version 3.0.

readXml(self, actionNode: QDomNode)

Reads an XML definition from actionNode into this object.

New in version 3.0.

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.

runable(self) → bool

Checks if the action is runable on the current platform

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.

setExpressionContextScope(self, scope: QgsExpressionContextScope)

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

New in version 3.0.

shortTitle(self) → str

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

type(self) → QgsAction.ActionType

The action type

writeXml(self, actionsNode: QDomNode)

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

New in version 3.0.