Class: QgsProcessingParameterDefinition¶
- class qgis.core.QgsProcessingParameterDefinition¶
Bases:
sip.wrapper
Base class for the definition of processing parameters.
Parameter definitions encapsulate properties regarding the behavior of parameters, their acceptable ranges, defaults, etc.
New in version 3.0.
QgsProcessingParameterDefinition(name: str, description: str = ‘’, defaultValue: Any = None, optional: bool = False, help: str = ‘’) Constructor for QgsProcessingParameterDefinition.
QgsProcessingParameterDefinition(
QgsProcessingParameterDefinition
)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.
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.Creates a clone of the parameter definition.
Returns the default value for the parameter.
Returns the default value to use for the parameter in a GUI.
Returns a list of other parameter names on which this parameter is dependent (e.g.
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.
Restores this parameter to a QVariantMap.
Returns the default value to use in the GUI for the parameter.
Returns the help for the parameter.
Returns
True
if this parameter represents a file or layer destination, e.g.Returns
True
if the parameter supports is dynamic, and can support data-defined values (i.e.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.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).
Unique parameter type name.
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).Attributes
- class Flag¶
Bases:
int
- FlagAdvanced = 2¶
- FlagHidden = 4¶
- FlagIsModelOutput = 16¶
- FlagOptional = 8¶
- class Flags¶
- class Flags(Union[QgsProcessingParameterDefinition.Flags, QgsProcessingParameterDefinition.Flag])
- class Flags(QgsProcessingParameterDefinition.Flags)
Bases:
sip.wrapper
- additionalExpressionContextVariables(self) List[str] ¶
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.
New in version 3.8.
- Return type:
List[str]
- algorithm(self) QgsProcessingAlgorithm ¶
Returns a pointer to the algorithm which owns this parameter. May be
None
for non-owned parameters.See also
- Return type:
- asPythonString(self, outputType: QgsProcessing.PythonOutputType = QgsProcessing.PythonQgsProcessingAlgorithmSubclass) str ¶
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.New in version 3.6.
- Parameters:
outputType (QgsProcessing.PythonOutputType = QgsProcessing.PythonQgsProcessingAlgorithmSubclass) –
- Return type:
str
- asScriptCode(self) str ¶
Returns the parameter definition encoded in a string which can be used within a Processing script.
- Return type:
str
- checkValueIsAcceptable(self, input: Any, context: QgsProcessingContext = None) bool ¶
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 (
QgsProcessingContext
= None) –
- Return type:
bool
- clone(self) QgsProcessingParameterDefinition ¶
Creates a clone of the parameter definition.
- Return type:
- defaultValue(self) Any ¶
Returns the default value for the parameter.
See also
See also
See also
- Return type:
Any
- defaultValueForGui(self) Any ¶
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.New in version 3.18.
- Return type:
Any
- dependsOnOtherParameters(self) List[str] ¶
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 ¶
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 ¶
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 ¶
Returns the property definition for dynamic properties.
See also
See also
See also
- Return type:
- flags(self) QgsProcessingParameterDefinition.Flags ¶
Returns any flags associated with the parameter.
See also
- Return type:
- fromVariantMap(self, map: Dict[str, Any]) bool ¶
Restores this parameter to a QVariantMap. Subclasses should ensure that they call the base class method.
See also
- Parameters:
map (Dict[str) –
- Return type:
bool
- guiDefaultValueOverride(self) Any ¶
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
New in version 3.18.
- Return type:
Any
- help(self) str ¶
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
New in version 3.16.
- Return type:
str
- isDestination(self) bool ¶
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 ¶
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 ¶
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 ¶
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:
- setAdditionalExpressionContextVariables(self, variables: Iterable[str])¶
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.
New in version 3.8.
- Parameters:
variables (Iterable[str]) –
- setDefaultValue(self, value: Any)¶
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)¶
Sets the
description
for the parameter. This is the user-visible string used to identify this parameter.See also
- Parameters:
description (str) –
- setDynamicLayerParameterName(self, name: str)¶
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 (str) –
- setDynamicPropertyDefinition(self, definition: QgsPropertyDefinition)¶
Sets the property
definition
for dynamic properties.See also
See also
See also
- Parameters:
definition (QgsPropertyDefinition) –
- setFlags(self, flags: QgsProcessingParameterDefinition.Flags | QgsProcessingParameterDefinition.Flag)¶
Sets the
flags
associated with the parameter.See also
- Parameters:
flags (Union[QgsProcessingParameterDefinition.Flags) –
- setGuiDefaultValueOverride(self, value: Any)¶
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
New in version 3.18.
- Parameters:
value (Any) –
- setHelp(self, help: str)¶
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
New in version 3.16.
- Parameters:
help (str) –
- setIsDynamic(self, dynamic: bool)¶
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])¶
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) –
- setName(self, name: str)¶
Sets the
name
of the parameter. This is the internal identifier by which algorithms access this parameter.See also
- Parameters:
name (str) –
- toVariantMap(self) Dict[str, Any] ¶
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]
- toolTip(self) str ¶
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
- type(self) str ¶
Unique parameter type name.
- Return type:
str
- valueAsJsonObject(self, value: Any, context: QgsProcessingContext) Any ¶
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
New in version 3.24.
- Parameters:
value (Any) –
context (QgsProcessingContext) –
- Return type:
Any
- valueAsPythonComment(self, value: Any, context: QgsProcessingContext) str ¶
Returns a Python comment explaining a parameter
value
, or an empty string if no comment is required.New in version 3.20.
- Parameters:
value (Any) –
context (QgsProcessingContext) –
- Return type:
str
- valueAsPythonString(self, value: Any, context: QgsProcessingContext) str ¶
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
- valueAsString(self, value: Any, context: QgsProcessingContext) Tuple[str, bool] ¶
Returns a string version of the parameter input
value
(if possible).- Parameters:
value (Any) – value to convert
context (QgsProcessingContext) – processing context
- Return type:
Tuple[str, bool]
- Returns:
value converted to string
ok: will be set to
True
if value could be represented as a string.
See also
See also
See also
New in version 3.24.
- valueAsStringList(self, value: Any, context: QgsProcessingContext) Tuple[List[str], bool] ¶
Returns a string list version of the parameter input
value
(if possible).- Parameters:
value (Any) – value to convert
context (QgsProcessingContext) – processing context
- Return type:
Tuple[List[str], bool]
- Returns:
value converted to string list
ok: will be set to
True
if value could be represented as a string list
See also
See also
See also
New in version 3.24.