Class: QgsProcessingParameterDefinition¶
-
class
qgis.core.
QgsProcessingParameterDefinition
(name: str, description: str = '', defaultValue: Any = None, optional: bool = False)¶ Bases:
sip.wrapper
Constructor for QgsProcessingParameterDefinition.
QgsProcessingParameterDefinition(
QgsProcessingParameterDefinition
)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.
- Parameters
name (str) –
description (str = '') –
defaultValue (Any = None) –
optional –
-
class
Flag
¶ Bases:
int
-
FlagAdvanced
= 2¶
-
FlagHidden
= 4¶
-
FlagIsModelOutput
= 16¶
-
FlagOptional
= 8¶
-
class
Flags
¶ Bases:
sip.wrapper
QgsProcessingParameterDefinition.Flags(Union[QgsProcessingParameterDefinition.Flags, QgsProcessingParameterDefinition.Flag]) QgsProcessingParameterDefinition.Flags(QgsProcessingParameterDefinition.Flags)
-
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
- 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
-
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
- 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: Union[QgsProcessingParameterDefinition.Flags, QgsProcessingParameterDefinition.Flag])¶ Sets the
flags
associated with the parameter.See also
- Parameters
flags (Union[QgsProcessingParameterDefinition.Flags) –
-
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
-
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.- Parameters
value (Any) –
context (QgsProcessingContext) –
- Return type
str