Class: QgsProcessingParameterEnum¶
- class qgis.core.QgsProcessingParameterEnum¶
Bases:
QgsProcessingParameterDefinition
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')] } })
New in version 3.0.
QgsProcessingParameterEnum(name: str, description: str = ‘’, options: Iterable[str] = [], allowMultiple: bool = False, defaultValue: Any = None, optional: bool = False, usesStaticStrings: bool = False) Constructor for QgsProcessingParameterEnum.
QgsProcessingParameterEnum(
QgsProcessingParameterEnum
)Methods
Returns
True
if the parameter allows multiple selected values.- param outputType
- rtype
str
- param input
- rtype
QgsProcessingParameterDefinition
Creates a new parameter using the definition from a script code.
- param map
Returns the list of acceptable options for the parameter.
Sets whether the parameter allows multiple selected values.
Sets the list of acceptable
options
for the parameter.Sets whether the parameter uses static (non-translated) string values for its enumeration choice list.
- rtype
Dict[str, Any]
- rtype
str
Returns the type name for the parameter class.
Returns
True
if the parameter uses static (non-translated) string values for its enumeration choice list.- param value
- param value
- allowMultiple(self) bool ¶
Returns
True
if the parameter allows multiple selected values.See also
- Return type
bool
- asPythonString(self, outputType: QgsProcessing.PythonOutputType = QgsProcessing.PythonQgsProcessingAlgorithmSubclass) str ¶
- Parameters
outputType (QgsProcessing.PythonOutputType = QgsProcessing.PythonQgsProcessingAlgorithmSubclass) –
- Return type
str
- asScriptCode(self) str ¶
- Return type
str
- checkValueIsAcceptable(self, input: Any, context: QgsProcessingContext = None) bool ¶
- Parameters
input (Any) –
context (
QgsProcessingContext
= None) –
- Return type
bool
- clone(self) QgsProcessingParameterDefinition ¶
- Return type
- fromScriptCode(name: str, description: str, isOptional: bool, definition: str) QgsProcessingParameterEnum ¶
Creates a new parameter using the definition from a script code.
- Parameters
name (str) –
description (str) –
isOptional (bool) –
definition (str) –
- Return type
- fromVariantMap(self, map: Dict[str, Any]) bool ¶
- Parameters
map (Dict[str) –
- Return type
bool
- options(self) List[str] ¶
Returns the list of acceptable options for the parameter.
See also
- Return type
List[str]
- setAllowMultiple(self, allowMultiple: bool)¶
Sets whether the parameter allows multiple selected values.
See also
- Parameters
allowMultiple (bool) –
- setOptions(self, options: Iterable[str])¶
Sets the list of acceptable
options
for the parameter.See also
- Parameters
options (Iterable[str]) –
- setUsesStaticStrings(self, usesStaticStrings: bool)¶
Sets whether the parameter uses static (non-translated) string values for its enumeration choice list.
See also
New in version 3.18.
- Parameters
usesStaticStrings (bool) –
- toVariantMap(self) Dict[str, Any] ¶
- Return type
Dict[str, Any]
- type(self) str ¶
- Return type
str
- typeName() str ¶
Returns the type name for the parameter class.
- Return type
str
- usesStaticStrings(self) bool ¶
Returns
True
if the parameter uses static (non-translated) string values for its enumeration choice list.See also
New in version 3.18.
- Return type
bool
- valueAsPythonComment(self, value: Any, context: QgsProcessingContext) str ¶
- Parameters
value (Any) –
context (QgsProcessingContext) –
- Return type
str
- valueAsPythonString(self, value: Any, context: QgsProcessingContext) str ¶
- Parameters
value (Any) –
context (QgsProcessingContext) –
- Return type
str