Class: QgsAction¶
Utility class that encapsulates an action based on vector attributes.
Enums
alias of |
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. |
|
Returns an HTML table with the basic information about this action. |
|
The icon |
|
The path to the icon |
|
Returns a unique id for this action. |
|
Returns whether only enabled in editable mode |
|
Returns |
|
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. |
|
Sets the action command. |
|
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. |
- 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 runshortTitle (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 runshortTitle (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
- 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
- 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 theactionScope()
.- Return type:
str
- expressionContextScope(self) QgsExpressionContextScope [source]¶
Returns an expression context scope used for running the action.
- Return type:
- html(self) str [source]¶
Returns an HTML table with the basic information about this action.
Added in version 3.24.
- Return type:
str
- 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
- 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:
layer (Optional[QgsVectorLayer])
feature (
QgsFeature
)expressionContext (
QgsExpressionContext
)
- 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: