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 runenabledOnlyWhenEditable – if
True
then action is only enable in editmode. Not available in Python bindings.
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 runshortTitle – 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. Not available in Python bindings.
QgsAction(
QgsAction
)Utility class that encapsulates an action based on vector attributes.
Methods
The action scopes define where an action will be available.
Whether to capture output for display when this action is run
Returns the command that is executed by this action.
Returns an expression context scope used for running the action.
The icon
The path to the icon
Returns a unique id for this action.
Returns whether only enabled in editable mode
Returns
True
if this action was a default constructed one.The name of the action.
Returns the notification message that triggers the action
Reads an XML definition from actionNode into this object.
Run this action.
Checks if the action is runable on the current platform
The action scopes define where an action will be available.
Set whether the action is only enabled in editable mode
Sets an expression context scope to use for running the action.
The short title is used to label user interface elements like buttons
The action type
Appends an XML definition for this action as a new child node to actionsNode.
Attributes
- 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
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 theactionScope()
.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
- 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
layer (QgsVectorLayer) –
feature (QgsFeature) –
expressionContext (QgsExpressionContext) –
- 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
- 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) –