Class: QgsAbstractProcessingParameterWidgetWrapper

class qgis.gui.QgsAbstractProcessingParameterWidgetWrapper

Bases: PyQt5.QtCore.QObject, QgsExpressionContextGenerator

A widget wrapper for Processing parameter value widgets.

Widget wrappers are used to create widgets for individual Processing parameters, and handle retrieving and setting the current value for those parameters.

Widget wrappers can be created for different dialog types, allowing different appearance and behavior of widgets depending on whether they are being created for use in a standard algorithm dialog, a batch processing dialog, or a modeler dialog.

Individual widget wrappers are not usually created directly, instead they are constructed through the central registry, via calls to QgsGui.processingGuiRegistry()->:py:func:~QgsProcessingParameterWidgetContext.createParameterWidgetWrapper.

New in version 3.4.

QgsAbstractProcessingParameterWidgetWrapper(parameter: QgsProcessingParameterDefinition = None, type: QgsProcessingGui.WidgetType = QgsProcessingGui.Standard, parent: QObject = None) Constructor for QgsAbstractProcessingParameterWidgetWrapper, for the specified parameter definition and dialog type.

Methods

childEvent

connectNotify

createExpressionContext

rtype

QgsExpressionContext

createLabel

Creates a new label to accompany widgets created by the wrapper.

createWidget

Creates a new widget which allows customization of the parameter's value.

createWrappedLabel

Creates and returns a new label to accompany widgets created by the wrapper.

createWrappedWidget

Creates and return a new wrapped widget which allows customization of the parameter's value.

customEvent

customProperties

Returns any custom properties set by the wrapper.

disconnectNotify

isSignalConnected

linkedVectorLayer

Returns the optional vector layer associated with this widget wrapper, or None if no vector layer is applicable.

parameterDefinition

Returns the parameter definition associated with this wrapper.

parameterValue

Returns the current value of the parameter.

postInitialize

Called after all wrappers have been created within a particular dialog or context, allowing the wrapper to connect to the wrappers of other, related parameters.

receivers

registerProcessingContextGenerator

Registers a Processing context generator class that will be used to retrieve a Processing context for the wrapper when required.

registerProcessingParametersGenerator

Registers a Processing parameters generator class that will be used to retrieve algorithm parameters for the wrapper when required (e.g.

sender

senderSignalIndex

setDialog

Sets the parent dialog in which the wrapper is shown.

setParameterValue

Sets the current value for the parameter.

setWidgetContext

Sets the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.

setWidgetValue

Sets the current value for the parameter to show in the widget.

stretch

Returns the Qt layout "stretch" factor to use when adding this widget to a layout.

timerEvent

type

Returns the dialog type for which widgets and labels will be created by this wrapper.

widgetContext

Returns the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.

widgetValue

Returns the current value of the parameter.

wrappedLabel

Returns the current wrapped label, if any.

wrappedWidget

Returns the current wrapped widget, if any.

Signals

widgetValueHasChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
createExpressionContext(self) QgsExpressionContext
Return type

QgsExpressionContext

createLabel(self) QLabel

Creates a new label to accompany widgets created by the wrapper.

The caller takes ownership of the returned label. Some parameter type and dialog type combinations will return None for this method. If None is returned, then no label should be shown for the parameter’s widget (i.e. the label is embedded inside the widget itself).

See also

createWidget()

Return type

QLabel

createWidget(self) QWidget

Creates a new widget which allows customization of the parameter’s value.

The caller takes ownership of the returned widget.

See also

createLabel()

Return type

QWidget

createWrappedLabel(self) QLabel

Creates and returns a new label to accompany widgets created by the wrapper.

The caller takes ownership of the returned label. Some parameter type and dialog type combinations will return None for this method. If None is returned, then no label should be shown for the parameter’s widget (i.e. the label is embedded inside the widget itself).

The wrapped label can be retrieved at a later stage by calling wrappedLabel().

Return type

QLabel

createWrappedWidget(self, context: QgsProcessingContext) QWidget

Creates and return a new wrapped widget which allows customization of the parameter’s value.

The caller takes ownership of the returned widget. The wrapped widget can be retrieved at a later stage by calling wrappedWidget().

The supplied context is used while initializing the widget to the parameter’s default value.

Parameters

context (QgsProcessingContext) –

Return type

QWidget

customEvent(self, QEvent)
customProperties(self) Dict[str, Any]

Returns any custom properties set by the wrapper.

Return type

Dict[str, Any]

disconnectNotify(self, QMetaMethod)
isSignalConnected(self, QMetaMethod) bool
linkedVectorLayer(self) QgsVectorLayer

Returns the optional vector layer associated with this widget wrapper, or None if no vector layer is applicable.

This is used to correctly generate expression contexts within the GUI, e.g. to allow expression buttons and property override buttons to correctly show the appropriate vector layer fields.

New in version 3.6.

Return type

QgsVectorLayer

property param

parameterDefinition(self) -> QgsProcessingParameterDefinition Returns the parameter definition associated with this wrapper.

Return type

QgsProcessingParameterDefinition

parameterDefinition(self) QgsProcessingParameterDefinition

Returns the parameter definition associated with this wrapper.

Return type

QgsProcessingParameterDefinition

parameterValue(self) Any

Returns the current value of the parameter.

Return type

Any

postInitialize(self, wrappers: Iterable[QgsAbstractProcessingParameterWidgetWrapper])

Called after all wrappers have been created within a particular dialog or context, allowing the wrapper to connect to the wrappers of other, related parameters.

Parameters

wrappers (Iterable[QgsAbstractProcessingParameterWidgetWrapper]) –

receivers(self, PYQT_SIGNAL) int
registerProcessingContextGenerator(self, generator: QgsProcessingContextGenerator)

Registers a Processing context generator class that will be used to retrieve a Processing context for the wrapper when required.

Care must be taken to call the base class implementation if overwrite this method.

Parameters

generator (QgsProcessingContextGenerator) –

registerProcessingParametersGenerator(self, generator: QgsProcessingParametersGenerator)

Registers a Processing parameters generator class that will be used to retrieve algorithm parameters for the wrapper when required (e.g. when a wrapper needs access to other parameter’s values).

New in version 3.14.

Parameters

generator (QgsProcessingParametersGenerator) –

sender(self) QObject
senderSignalIndex(self) int
setDialog(self, dialog: QDialog)

Sets the parent dialog in which the wrapper is shown.

New in version 3.8.

Parameters

dialog (QDialog) –

setParameterValue(self, value: Any, context: QgsProcessingContext)

Sets the current value for the parameter.

The context argument is used to specify the wider Processing context which the current value is associated with.

See also

parameterValue()

Parameters
setWidgetContext(self, context: QgsProcessingParameterWidgetContext)

Sets the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.

Subclasses should take care to call the base class method when reimplementing this method.

See also

widgetContext()

Parameters

context (QgsProcessingParameterWidgetContext) –

setWidgetValue(self, value: Any, context: QgsProcessingContext)

Sets the current value for the parameter to show in the widget.

The context argument is used to specify the wider Processing context which the current value is associated with.

See also

widgetValue()

Parameters
stretch(self) int

Returns the Qt layout “stretch” factor to use when adding this widget to a layout.

The default implementation returns 0.

New in version 3.14.

Return type

int

timerEvent(self, QTimerEvent)
type(self) QgsProcessingGui.WidgetType

Returns the dialog type for which widgets and labels will be created by this wrapper.

Return type

QgsProcessingGui.WidgetType

widgetContext(self) QgsProcessingParameterWidgetContext

Returns the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.

Return type

QgsProcessingParameterWidgetContext

widgetValue(self) Any

Returns the current value of the parameter.

See also

setWidgetValue()

Return type

Any

widgetValueHasChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type

PYQT_SIGNAL

wrappedLabel(self) QLabel

Returns the current wrapped label, if any.

Return type

QLabel

wrappedWidget(self) QWidget

Returns the current wrapped widget, if any.

Return type

QWidget