Class: QgsProcessingParameterEnum

An enum based parameter for processing algorithms, allowing for selection from predefined values.

Since QGIS 3.24 a list of icons corresponding to the enum values can be specified by setting the widget wrapper metadata “icons” option, as demonstrated below. The “icons” value should be set to a list of QIcon values.

param = QgsProcessingParameterEnum( 'FIELD_TYPE', 'Field type', ['Integer', 'String'])
param.setMetadata( {'widget_wrapper':
  { 'icons': [QIcon('integer.svg'), QIcon('string.svg')] }
})

Class Hierarchy

Inheritance diagram of qgis.core.QgsProcessingParameterEnum

Base classes

QgsProcessingParameterDefinition

Base class for the definition of processing parameters.

class qgis.core.QgsProcessingParameterEnum[source]

Bases: QgsProcessingParameterDefinition

__init__(name: str | None, description: str | None = '', options: Iterable[str | None] = [], allowMultiple: bool = False, defaultValue: Any = None, optional: bool = False, usesStaticStrings: bool = False)

Constructor for QgsProcessingParameterEnum.

Parameters:
  • name (Optional[str])

  • description (Optional[str] = '')

  • options (Iterable[Optional[str]] = [])

  • allowMultiple (bool = False)

  • defaultValue (Any = None)

  • optional (bool = False)

  • usesStaticStrings (bool = False)

__init__(a0: QgsProcessingParameterEnum)
Parameters:

a0 (QgsProcessingParameterEnum)

allowMultiple(self) bool[source]

Returns True if the parameter allows multiple selected values.

Return type:

bool

static fromScriptCode(name: str | None, description: str | None, isOptional: bool, definition: str | None) QgsProcessingParameterEnum | None[source]

Creates a new parameter using the definition from a script code.

Parameters:
  • name (Optional[str])

  • description (Optional[str])

  • isOptional (bool)

  • definition (Optional[str])

Return type:

Optional[QgsProcessingParameterEnum]

options(self) List[str][source]

Returns the list of acceptable options for the parameter.

See also

setOptions()

Return type:

List[str]

setAllowMultiple(self, allowMultiple: bool)[source]

Sets whether the parameter allows multiple selected values.

See also

allowMultiple()

Parameters:

allowMultiple (bool)

setOptions(self, options: Iterable[str | None])[source]

Sets the list of acceptable options for the parameter.

See also

options()

Parameters:

options (Iterable[Optional[str]])

setUsesStaticStrings(self, usesStaticStrings: bool)[source]

Sets whether the parameter uses static (non-translated) string values for its enumeration choice list.

Added in version 3.18.

Parameters:

usesStaticStrings (bool)

static typeName() str[source]

Returns the type name for the parameter class.

Return type:

str

usesStaticStrings(self) bool[source]

Returns True if the parameter uses static (non-translated) string values for its enumeration choice list.

Added in version 3.18.

Return type:

bool