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: Methods

algorithm Returns a pointer to the algorithm which owns this parameter.
asScriptCode Returns the parameter definition encoded in a string which can be used within a Python processing script.
checkValueIsAcceptable Checks whether the specified input value is acceptable for the parameter.
clone Creates a clone of the parameter definition.
defaultValue Returns the default value for the parameter.
dependsOnOtherParameters Returns a list of other parameter names on which this parameter is dependent (e.g.
description Returns the description for the parameter.
dynamicLayerParameterName Returns the name of the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.
dynamicPropertyDefinition Returns the property definition for dynamic properties.
flags Returns any flags associated with the parameter.
fromVariantMap Restores this parameter to a QVariantMap.
isDestination Returns true if this parameter represents a file or layer destination, e.g.
isDynamic Returns true if the parameter supports is dynamic, and can support data-defined values (i.e.
metadata Returns the parameter’s freeform metadata.
name Returns the name of the parameter.
provider Returns a pointer to the provider for the algorithm which owns this parameter.
setDefaultValue Sets the default value for the parameter.
setDescription Sets the description for the parameter.
setDynamicLayerParameterName Sets the name for the parameter for a layer linked to a dynamic parameter, or an empty string if this is not set.
setDynamicPropertyDefinition Sets the property definition for dynamic properties.
setFlags Sets the flags associated with the parameter.
setIsDynamic Sets whether the parameter is dynamic, and can support data-defined values (i.e.
setMetadata Sets the parameter’s freeform metadata.
setName Sets the name of the parameter.
toVariantMap Saves this parameter to a QVariantMap.
toolTip 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).
type Unique parameter type name.
valueAsPythonString 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.

Signals

Attributes

FlagAdvanced
FlagHidden
FlagIsModelOutput
FlagOptional
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)

algorithm(self) → QgsProcessingAlgorithm

Returns a pointer to the algorithm which owns this parameter. May be None for non-owned parameters.

See also

provider()

asScriptCode(self) → str

Returns the parameter definition encoded in a string which can be used within a Python processing script.

checkValueIsAcceptable(self, input: Any, context: QgsProcessingContext = None) → bool

Checks whether the specified input value is acceptable for the parameter. Returns true if the value can be accepted. The optional context 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.

clone(self) → QgsProcessingParameterDefinition

Creates a clone of the parameter definition.

defaultValue(self) → Any

Returns the default value for the parameter.

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).

description(self) → str

Returns the description for the parameter. This is the user-visible string used to identify this parameter.

See also

setDescription()

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

isDynamic()

dynamicPropertyDefinition(self) → QgsPropertyDefinition

Returns the property definition for dynamic properties.

See also

isDynamic()

flags(self) → QgsProcessingParameterDefinition.Flags

Returns any flags associated with the parameter.

See also

setFlags()

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

toVariantMap()

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 return true.

isDynamic(self) → bool

Returns true if the parameter supports is dynamic, and can support data-defined values (i.e. QgsProperty based values).

See also

setIsDynamic()

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

setMetadata()

name(self) → str

Returns the name of the parameter. This is the internal identifier by which algorithms access this parameter.

See also

setName()

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

algorithm()

setDefaultValue(self, value: Any)

Sets the default value for the parameter. Caller takes responsibility to ensure that value is a valid input for the parameter subclass.

See also

defaultValue()

setDescription(self, description: str)

Sets the description for the parameter. This is the user-visible string used to identify this parameter.

See also

description()

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

isDynamic()

setDynamicPropertyDefinition(self, definition: QgsPropertyDefinition)

Sets the property definition for dynamic properties.

See also

isDynamic()

setFlags(self, flags: Union[QgsProcessingParameterDefinition.Flags, QgsProcessingParameterDefinition.Flag])

Sets the flags associated with the parameter.

See also

flags()

setIsDynamic(self, dynamic: bool)

Sets whether the parameter is dynamic, and can support data-defined values (i.e. QgsProperty based values).

See also

isDynamic()

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

metadata()

setName(self, name: str)

Sets the name of the parameter. This is the internal identifier by which algorithms access this parameter.

See also

name()

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

fromVariantMap()

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).

type(self) → str

Unique parameter type name.

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. The returned value must be correctly escaped - e.g. string values must be wrapped in ‘ ‘s.