Class: QgsProcessingParameterDefinition¶
Base class for the definition of processing parameters.
Parameter definitions encapsulate properties regarding the behavior of parameters, their acceptable ranges, defaults, etc.
Note
This is an abstract class, with methods which must be implemented by a subclass.
Class Hierarchy¶
Subclasses¶
Base class for all parameter definitions which represent file or layer destinations, e.g. parameters which are used for the destination for layers output by an algorithm. |
|
A parameter for “aggregate” configurations, which consist of a definition of desired output fields, types, and aggregate used to populate them. |
|
A parameter for Processing algorithms specifying how rasters should be aligned. |
|
An annotation layer parameter for processing algorithms. |
|
A numeric parameter for processing algorithms. |
|
A string parameter for authentication configuration ID values. |
|
A raster band parameter for Processing algorithms. |
|
A boolean parameter for processing algorithms. |
|
A color parameter for processing algorithms. |
|
A coordinate operation parameter for processing algorithms. |
|
A coordinate reference system parameter for processing algorithms. |
|
A database schema parameter for processing algorithms, allowing users to select from existing schemas on a registered database connection. |
|
A database table name parameter for processing algorithms. |
|
A datetime (or pure date or time) parameter for processing algorithms. |
|
A parameter for Processing algorithms that need a list of input vector layers to export as DXF file. |
|
An enum based parameter for processing algorithms, allowing for selection from predefined values. |
|
An expression parameter for processing algorithms. |
|
A rectangular map extent parameter for processing algorithms. |
|
An input feature source (such as vector layers) parameter for processing algorithms. |
|
A vector layer or feature source field parameter for processing algorithms. |
|
A parameter for “field mapping” configurations, which consist of a definition of desired output fields, types, and expressions used to populate them. |
|
An input file or folder parameter for processing algorithms. |
|
A geometry parameter for processing algorithms. |
|
A print layout parameter, allowing users to select a print layout. |
|
A print layout item parameter, allowing users to select a particular item from a print layout. |
|
A map layer parameter for processing algorithms. |
|
A map theme parameter for processing algorithms, allowing users to select an existing map theme from a project. |
|
A table (matrix) parameter for processing algorithms. |
|
A parameter for processing algorithms that need a list of mesh dataset groups. |
|
A parameter for processing algorithms that need a list of mesh dataset index from time parameter. |
|
A mesh layer parameter for processing algorithms. |
|
A parameter for processing algorithms which accepts multiple map layers. |
|
A point parameter for processing algorithms. |
|
A point cloud layer attribute parameter for Processing algorithms. |
|
A point cloud layer parameter for processing algorithms. |
|
A data provider connection parameter for processing algorithms, allowing users to select from available registered connections for a particular data provider. |
|
A numeric range parameter for processing algorithms. |
|
A raster layer parameter for processing algorithms. |
|
A string parameter for processing algorithms. |
|
A parameter for processing algorithms that need a list of input vector layers to construct a TIN. |
|
A vector layer (with or without geometry) parameter for processing algorithms. |
|
A parameter for Processing algorithms that need a list of input vector layers for writing of vector tiles. |
Enums
alias of |
Abstract Methods
Creates a clone of the parameter definition. |
|
Unique parameter type name. |
Methods
Returns a list of additional expression context variables which are available for use when evaluating this parameter. |
|
Returns a pointer to the algorithm which owns this parameter. |
|
Default gui value for an algorithm parameter from settings |
|
Returns the default value for the parameter. |
|
Returns the default value to use for the parameter in a GUI. |
|
Returns the description for the parameter. |
|
Returns the name of the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set. |
|
Returns the property definition for dynamic properties. |
|
Returns any flags associated with the parameter. |
|
Returns the default value to use in the GUI for the parameter. |
|
Returns the help for the parameter. |
|
Returns |
|
Returns the parameter's freeform metadata. |
|
Returns the name of the parameter. |
|
Returns a pointer to the provider for the algorithm which owns this parameter. |
|
Sets a list of additional expression context variables which are available for use when evaluating this parameter. |
|
Sets the default value for the parameter. |
|
Sets the description for the parameter. |
|
Sets the name for the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set. |
|
Sets the property definition for dynamic properties. |
|
Sets the flags associated with the parameter. |
|
Sets the default value to use for the parameter in GUI widgets. |
|
Sets the help for the parameter. |
|
Sets whether the parameter is dynamic, and can support data-defined values (i.e. |
|
Sets the parameter's freeform metadata. |
|
Sets the name of the parameter. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsProcessingParameterDefinition. See the FAQ for more details.
Returns the parameter definition as a Python command which can be used within a Python Processing script. |
|
Returns the parameter definition encoded in a string which can be used within a Processing script. |
|
Checks whether the specified input value is acceptable for the parameter. |
|
Returns a list of other parameter names on which this parameter is dependent (e.g. field parameters which depend on a parent layer parameter). |
|
Restores this parameter to a QVariantMap. |
|
Returns |
|
Saves this parameter to a QVariantMap. |
|
Returns a formatted tooltip for use with the parameter, which gives helpful information like parameter description, ID, and extra content like default values (depending on parameter type). |
|
Returns a version of the parameter input value, which is suitable for use in a JSON object. |
|
Returns a Python comment explaining a parameter value, or an empty string if no comment is required. |
|
Returns a string version of the parameter input value, which is suitable for use as an input parameter value when running an algorithm directly from a Python command. |
|
Returns a string version of the parameter input value (if possible). |
|
Returns a string list version of the parameter input value (if possible). |
- class qgis.core.QgsProcessingParameterDefinition[source]¶
Bases:
object
- __init__(name: str | None, description: str | None = '', defaultValue: Any = None, optional: bool = False, help: str | None = '')
Constructor for QgsProcessingParameterDefinition.
- Parameters:
name (Optional[str])
description (Optional[str] = '')
defaultValue (Any = None)
optional (bool = False)
help (Optional[str] = '')
- __init__(a0: QgsProcessingParameterDefinition)
- Parameters:
- Flag¶
alias of
ProcessingParameterFlag
- Flags¶
alias of
ProcessingParameterFlags
- additionalExpressionContextVariables(self) List[str] [source]¶
Returns a list of additional expression context variables which are available for use when evaluating this parameter.
The additional variables will be added to the variables exposed from the usual expression context available to the parameter. They can be used to expose variables which are ONLY available to this parameter.
The returned list should contain the variable names only, without the usual “@” prefix.
Added in version 3.8.
- Return type:
List[str]
- algorithm(self) QgsProcessingAlgorithm | None [source]¶
Returns a pointer to the algorithm which owns this parameter. May be
None
for non-owned parameters.See also
- Return type:
Optional[QgsProcessingAlgorithm]
- virtual asPythonString(self, outputType: QgsProcessing.PythonOutputType = QgsProcessing.PythonOutputType.PythonQgsProcessingAlgorithmSubclass) str [source]¶
Returns the parameter definition as a Python command which can be used within a Python Processing script.
The
outputType
argument specifies the desired output format for the Python string, i.e. the intended end use of the generated Python code.Added in version 3.6.
- Parameters:
outputType (QgsProcessing.PythonOutputType = QgsProcessing.PythonOutputType.PythonQgsProcessingAlgorithmSubclass)
- Return type:
str
- virtual asScriptCode(self) str [source]¶
Returns the parameter definition encoded in a string which can be used within a Processing script.
- Return type:
str
- virtual checkValueIsAcceptable(self, input: Any, context: QgsProcessingContext | None = None) bool [source]¶
Checks whether the specified
input
value is acceptable for the parameter. ReturnsTrue
if the value can be accepted. The optionalcontext
parameter can be specified to allow a more stringent check to be performed, capable of checking for the presence of required layers and other factors within the context.- Parameters:
input (Any)
context (Optional[QgsProcessingContext] = None)
- Return type:
bool
- abstract clone(self) QgsProcessingParameterDefinition | None [source]¶
Creates a clone of the parameter definition.
- Return type:
Optional[QgsProcessingParameterDefinition]
- defaultGuiValueFromSetting(self) Any [source]¶
Default gui value for an algorithm parameter from settings
- Return type:
Any
- Returns:
default value from settings or invalid QVariant if there is no default value defined in the settings
Added in version 3.34.
- defaultValue(self) Any [source]¶
Returns the default value for the parameter.
See also
See also
See also
- Return type:
Any
- defaultValueForGui(self) Any [source]¶
Returns the default value to use for the parameter in a GUI.
This will be the parameter’s
defaultValue()
, unless aguiDefaultValueOverride()
is set to override that.Added in version 3.18.
- Return type:
Any
- virtual dependsOnOtherParameters(self) List[str] [source]¶
Returns a list of other parameter names on which this parameter is dependent (e.g. field parameters which depend on a parent layer parameter).
- Return type:
List[str]
- description(self) str [source]¶
Returns the description for the parameter. This is the user-visible string used to identify this parameter.
See also
- Return type:
str
- dynamicLayerParameterName(self) str [source]¶
Returns the name of the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.
Dynamic parameters (see
isDynamic()
) can have an optional vector layer parameter linked to them, which indicates which layer the fields and values will be available from when evaluating the dynamic parameter.See also
See also
See also
- Return type:
str
- dynamicPropertyDefinition(self) QgsPropertyDefinition [source]¶
Returns the property definition for dynamic properties.
See also
See also
See also
- Return type:
- flags(self) Qgis.ProcessingParameterFlags [source]¶
Returns any flags associated with the parameter.
See also
- Return type:
- virtual fromVariantMap(self, map: Dict[str, Any]) bool [source]¶
Restores this parameter to a QVariantMap. Subclasses should ensure that they call the base class method.
See also
- Parameters:
map (Dict[str, Any])
- Return type:
bool
- guiDefaultValueOverride(self) Any [source]¶
Returns the default value to use in the GUI for the parameter.
Usually this will return an invalid variant, which indicates that the standard
defaultValue()
will be used in the GUI.See also
See also
See also
Added in version 3.18.
- Return type:
Any
- help(self) str [source]¶
Returns the help for the parameter.
This is a descriptive (possibly lengthy), translated string explaining the parameter’s behavior and use in depth.
See also
Added in version 3.16.
- Return type:
str
- virtual isDestination(self) bool [source]¶
Returns
True
if this parameter represents a file or layer destination, e.g. parameters which are used for the destination for layers output by an algorithm will returnTrue
.- Return type:
bool
- isDynamic(self) bool [source]¶
Returns
True
if the parameter supports is dynamic, and can support data-defined values (i.e.QgsProperty
based values).See also
See also
See also
- Return type:
bool
- metadata(self) Dict[str, Any] ¶
Returns the parameter’s freeform metadata. This is mostly used by parameter widget wrappers in order to customize their appearance and behavior.
See also
- Return type:
Dict[str, Any]
- name(self) str [source]¶
Returns the name of the parameter. This is the internal identifier by which algorithms access this parameter.
See also
- Return type:
str
- provider(self) QgsProcessingProvider | None [source]¶
Returns a pointer to the provider for the algorithm which owns this parameter. May be
None
for non-owned parameters or algorithms.See also
- Return type:
Optional[QgsProcessingProvider]
- setAdditionalExpressionContextVariables(self, variables: Iterable[str | None])[source]¶
Sets a list of additional expression context
variables
which are available for use when evaluating this parameter.The additional variables will be added to the variables exposed from the usual expression context available to the parameter. They can be used to expose variables which are ONLY available to this parameter.
The
variables
list should contain the variable names only, without the usual “@” prefix.Note
Specifying variables via this method is for metadata purposes only. It is the algorithm’s responsibility to correctly set the value of these additional variables in all expression context used when evaluating the parameter, in whichever way is appropriate for that particular variable.
Added in version 3.8.
- Parameters:
variables (Iterable[Optional[str]])
- setDefaultValue(self, value: Any)[source]¶
Sets the default
value
for the parameter. Caller takes responsibility to ensure thatvalue
is a valid input for the parameter subclass.See also
See also
- Parameters:
value (Any)
- setDescription(self, description: str | None)[source]¶
Sets the
description
for the parameter. This is the user-visible string used to identify this parameter.See also
- Parameters:
description (Optional[str])
- setDynamicLayerParameterName(self, name: str | None)[source]¶
Sets the
name
for the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.Dynamic parameters (see
isDynamic()
) can have an optional vector layer parameter linked to them, which indicates which layer the fields and values will be available from when evaluating the dynamic parameter.See also
See also
See also
- Parameters:
name (Optional[str])
- setDynamicPropertyDefinition(self, definition: QgsPropertyDefinition)[source]¶
Sets the property
definition
for dynamic properties.See also
See also
See also
- Parameters:
definition (QgsPropertyDefinition)
- setFlags(self, flags: Qgis.ProcessingParameterFlags | Qgis.ProcessingParameterFlag)[source]¶
Sets the
flags
associated with the parameter.See also
- Parameters:
flags (Union[Qgis.ProcessingParameterFlags, Qgis.ProcessingParameterFlag])
- setGuiDefaultValueOverride(self, value: Any)[source]¶
Sets the default
value
to use for the parameter in GUI widgets. Caller takes responsibility to ensure thatvalue
is a valid input for the parameter subclass.Usually the
guiDefaultValueOverride()
is a invalid variant, which indicates that the standarddefaultValue()
should be used in the GUI. In cases where it is decided that a previous default value was inappropriate, setting a non-invalid default GUI value can be used to change the default value for the parameter shown to users when running algorithms without changing the actualdefaultValue()
and potentially breaking third party scripts.See also
See also
Added in version 3.18.
- Parameters:
value (Any)
- setHelp(self, help: str | None)[source]¶
Sets the
help
for the parameter.The
help
string should be a descriptive, translated string explaining the parameter’s behavior and use in depth.See also
Added in version 3.16.
- Parameters:
help (Optional[str])
- setIsDynamic(self, dynamic: bool)[source]¶
Sets whether the parameter is
dynamic
, and can support data-defined values (i.e.QgsProperty
based values).See also
See also
See also
- Parameters:
dynamic (bool)
- setMetadata(self, metadata: Dict[str, Any])[source]¶
Sets the parameter’s freeform
metadata
. This is mostly used by parameter widget wrappers in order to customize their appearance and behavior.See also
- Parameters:
metadata (Dict[str, Any])
- setName(self, name: str | None)[source]¶
Sets the
name
of the parameter. This is the internal identifier by which algorithms access this parameter.See also
- Parameters:
name (Optional[str])
- virtual toVariantMap(self) Dict[str, Any] [source]¶
Saves this parameter to a QVariantMap. Subclasses should ensure that they call the base class method and then extend the result with additional properties.
See also
- Return type:
Dict[str, Any]
- virtual toolTip(self) str [source]¶
Returns a formatted tooltip for use with the parameter, which gives helpful information like parameter description, ID, and extra content like default values (depending on parameter type).
- Return type:
str
- virtual valueAsJsonObject(self, value: Any, context: QgsProcessingContext) Any [source]¶
Returns a version of the parameter input
value
, which is suitable for use in a JSON object.This method must return only simple values which can be losslessly encapsulated in a serialized JSON map. For instance, any QGIS class values (such as
QgsCoordinateReferenceSystem
) must be converted to a simple string or numeric value equivalent.See also
See also
Added in version 3.24.
- Parameters:
value (Any)
context (QgsProcessingContext)
- Return type:
Any
- virtual valueAsPythonComment(self, value: Any, context: QgsProcessingContext) str [source]¶
Returns a Python comment explaining a parameter
value
, or an empty string if no comment is required.Added in version 3.20.
- Parameters:
value (Any)
context (QgsProcessingContext)
- Return type:
str
- virtual valueAsPythonString(self, value: Any, context: QgsProcessingContext) str [source]¶
Returns a string version of the parameter input
value
, which is suitable for use as an input parameter value when running an algorithm directly from a Python command.See also
See also
- Parameters:
value (Any)
context (QgsProcessingContext)
- Return type:
str
- virtual valueAsString(self, value: Any, context: QgsProcessingContext)[source]¶
Returns a string version of the parameter input
value
(if possible).- Parameters:
value (Any) – value to convert
context (
QgsProcessingContext
) -> (str) – processing context
- Returns:
value converted to string
ok:
True
if value could be represented as a string.
See also
See also
See also
Added in version 3.24.
- virtual valueAsStringList(self, value: Any, context: QgsProcessingContext)[source]¶
Returns a string list version of the parameter input
value
(if possible).- Parameters:
value (Any) – value to convert
context (
QgsProcessingContext
) -> (List[str]) – processing context
- Returns:
value converted to string list
ok:
True
if value could be represented as a string list
See also
See also
See also
Added in version 3.24.