Class: QgsProcessingAlgorithmWidgetBase¶
Base class for widgets which contain settings for running Processing algorithms.
Note
This is not considered stable API and may change in future QGIS versions.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: QgsProcessingParametersGenerator.createProcessingParameters(), QgsProcessingContextGenerator.processingContext()
List of all members, including inherited members
Class Hierarchy¶
Base classes¶
An interface for objects which can create sets of parameter values for processing algorithms. |
|
An interface for objects which can create Processing contexts. |
Subclasses¶
Base class for processing batch algorithm dialogs. |
Constructor
Enums
Log format options. |
|
Widget modes. |
Methods
Returns the algorithm running in the widget. |
|
Applies any defined overrides for Processing context settings to the specified context. |
|
Blocks run and changeParameters buttons and parameters tab while the algorithm is running. |
|
Returns the widget's button box. |
|
Cancels any algorithm currently running through the widget. |
|
Returns the widget's cancel button. |
|
Returns the widget's change parameters button. |
|
Clears the current log contents. |
|
Clears any current progress from the widget. |
|
Copies the current log contents to the clipboard. |
|
Creates a new processing feedback object, automatically connected to the appropriate slots in this widget. |
|
Creates a modal progress dialog showing progress and log messages from this widget. |
|
Forces the widget to close by detaching any running task from the widget THEN closing the widget. |
|
Hides the short help panel. |
|
Returns the logging level to use when running algorithms from the widget. |
|
Returns the main widget for the widget, usually a panel for configuring algorithm parameters. |
|
Returns the widget's message bar. |
|
Pushes command info to the widget's log. |
|
Pushes a console info string to the widget's log. |
|
Pushes a debug info string to the widget's log. |
|
Pushes a pre-formatted message to the widget's log |
|
Pushes an information string to the widget's log. |
|
Pushes a warning information string to the widget's log. |
|
Registers a generator for creating |
|
Reports an error string to the widget's log. |
|
Resets the widget's GUI, ready for another algorithm execution. |
|
Returns the results returned by the algorithm executed. |
|
Returns the widget's run button. |
|
Opens a dialog allowing users to save the current log contents. |
|
Saves the log contents to a text file (specified by the file path), in the given format. |
|
Sets the algorithm to run in the widget. |
|
Sets the current task running in the widget. |
|
Sets whether the algorithm was executed through the widget. |
|
Sets whether the algorithm was executed through the widget (no matter the result). |
|
Displays an info message in the widget's log. |
|
Sets the logging level to use when running algorithms from the widget. |
|
Sets the main widget for the widget, usually a panel for configuring algorithm parameters. |
|
Sets the percentage progress for the widget, between 0 and 100. |
|
Sets a progress text message. |
|
Sets the algorithm results. |
|
Switches the widget to the log page. |
|
Switches the widget to the parameters page. |
|
Shows and raises the widget |
|
Returns the widget's tab widget. |
|
Sets visibility for mutually exclusive buttons Run and Change Parameters. |
|
Returns |
Virtual Methods
In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsProcessingAlgorithmWidgetBase. See the FAQ for more details.
Called when an algorithm task has completed. |
|
For subclasses to register their own GUI controls to be blocked while the algorithm is running. |
|
Called when the algorithm has finished executing. |
|
Returns |
|
Returns |
|
For subclasses to register their own GUI controls to be reset, ready for another algorithm execution. |
|
Called when the widget's algorithm should be run. |
|
Sets the parameter values to show in the widget. |
Static Methods
Formats an input string for display in the log tab. |
Signals
Emitted when the algorithm is about to run in the specified context. |
|
Emitted whenever an algorithm has finished executing in the widget. |
- class qgis.gui.QgsProcessingAlgorithmWidgetBase[source]¶
Bases:
QDialog,QgsProcessingParametersGenerator,QgsProcessingContextGenerator- __init__(parent: QWidget | None = None, mode: QgsProcessingAlgorithmWidgetBase.WidgetMode = QgsProcessingAlgorithmWidgetBase.WidgetMode.Single)¶
Constructor for QgsProcessingAlgorithmWidgetBase.
- Parameters:
parent (Optional[QWidget] = None)
mode (QgsProcessingAlgorithmWidgetBase.WidgetMode = QgsProcessingAlgorithmWidgetBase.WidgetMode.Single)
- class LogFormat(*values)¶
Bases:
IntEnumLog format options.
Added in version 3.2.
FormatPlainText: Plain text file (.txt)FormatHtml: HTML file (.html)
- FormatHtml = 1¶
- FormatPlainText = 0¶
- class WidgetMode(*values)¶
Bases:
IntEnumWidget modes.
Added in version 3.24.
Single: Single algorithm execution modeBatch: Batch processing mode
- Batch = 1¶
- Single = 0¶
- virtual algExecuted(self, successful: bool, results: dict[str | None, Any])[source]¶
Called when an algorithm task has completed.
Added in version 3.26.
- algorithm(self) QgsProcessingAlgorithm | None[source]¶
Returns the algorithm running in the widget.
See also
- Return type:
- signal algorithmAboutToRun(context: QgsProcessingContext)[source]¶
Emitted when the algorithm is about to run in the specified
context.This signal can be used to tweak the
contextprior to the algorithm execution.Added in version 3.38.
- Parameters:
context (QgsProcessingContext)
- signal algorithmFinished(successful: bool, result: Dict[str, object])[source]¶
Emitted whenever an algorithm has finished executing in the widget.
Added in version 3.14.
- Parameters:
successful (bool)
result (Dict[str, object])
- applyContextOverrides(self, context: QgsProcessingContext | None)[source]¶
Applies any defined overrides for Processing context settings to the specified
context.This allows the widget to override default Processing settings for an individual algorithm execution.
Added in version 3.32.
- Parameters:
context (Optional[QgsProcessingContext])
- virtual blockAdditionalControlsWhileRunning(self)[source]¶
For subclasses to register their own GUI controls to be blocked while the algorithm is running.
- blockControlsWhileRunning(self)[source]¶
Blocks run and changeParameters buttons and parameters tab while the algorithm is running.
- buttonBox(self) QDialogButtonBox | None[source]¶
Returns the widget’s button box.
- Return type:
Optional[QDialogButtonBox]
- cancel(self)[source]¶
Cancels any algorithm currently running through the widget.
Note
The cancellation is non-blocking, and may take some time to complete. Some algorithms ignore cancellation requests entirely. This method returns immediately after requesting the cancellation, but the algorithm may still be running after return.
Added in version 4.2.
- cancelButton(self) QPushButton | None[source]¶
Returns the widget’s cancel button.
- Return type:
Optional[QPushButton]
- changeParametersButton(self) QPushButton | None[source]¶
Returns the widget’s change parameters button.
- Return type:
Optional[QPushButton]
- copyLogToClipboard(self)[source]¶
Copies the current log contents to the clipboard.
Added in version 3.2.
- createFeedback(self) QgsProcessingFeedback | None[source]¶
Creates a new processing feedback object, automatically connected to the appropriate slots in this widget.
See also
registerProcessingFeedbackFactory()- Return type:
- createProgressDialog(self) QDialog | None[source]¶
Creates a modal progress dialog showing progress and log messages from this widget.
- Return type:
Optional[QDialog]
- virtual finished(self, successful: bool, result: dict[str | None, Any], context: QgsProcessingContext, feedback: QgsProcessingFeedback | None)[source]¶
Called when the algorithm has finished executing.
- Parameters:
successful (bool)
context (QgsProcessingContext)
feedback (Optional[QgsProcessingFeedback])
- forceClose(self)[source]¶
Forces the widget to close by detaching any running task from the widget THEN closing the widget.
Added in version 4.2.
- static formatStringForLog(string: str | None) str[source]¶
Formats an input
stringfor display in the log tab.- Parameters:
string (Optional[str])
- Return type:
str
- virtual isFinalized(self) bool[source]¶
Returns
Trueif the widget is all finalized and can be safely deleted.Added in version 3.26.
- Return type:
bool
- virtual isRunning(self) bool[source]¶
Returns
Trueif the widget is currently running an algorithm.If the algorithm has not yet started or has finished executing then
Falsewill be returned.Note
Unlike the
isFinalized()method,isRunning()only provides information about the state of widget and is not tied to the deletion mechanisms of the widget.See also
Added in version 4.2.
- Return type:
bool
- logLevel(self) Qgis.ProcessingLogLevel[source]¶
Returns the logging level to use when running algorithms from the widget.
See also
Added in version 3.20.
- Return type:
- mainWidget(self) QgsPanelWidget | None[source]¶
Returns the main widget for the widget, usually a panel for configuring algorithm parameters.
See also
- Return type:
- messageBar(self) QgsMessageBar | None[source]¶
Returns the widget’s message bar.
- Return type:
- pushCommandInfo(self, info: str | None)[source]¶
Pushes command info to the widget’s log.
- Parameters:
info (Optional[str])
- pushConsoleInfo(self, info: str | None)[source]¶
Pushes a console info string to the widget’s log.
- Parameters:
info (Optional[str])
- pushDebugInfo(self, message: str | None)[source]¶
Pushes a debug info string to the widget’s log.
- Parameters:
message (Optional[str])
- pushFormattedMessage(self, html: str | None)[source]¶
Pushes a pre-formatted message to the widget’s log
This can be used to push formatted HTML messages to the widget.
Added in version 3.36.
- Parameters:
html (Optional[str])
- pushInfo(self, info: str | None)[source]¶
Pushes an information string to the widget’s log.
- Parameters:
info (Optional[str])
- pushWarning(self, warning: str | None)[source]¶
Pushes a warning information string to the widget’s log.
- Parameters:
warning (Optional[str])
- registerProcessingFeedbackGenerator(self, generator: QgsProcessingFeedbackGenerator | None)[source]¶
Registers a
generatorfor creatingQgsProcessingFeedbackobjects for use in the widget.Ownership of
generatoris not transferred, the caller is responsible for ensuring that it exists for the lifetime of the widget.If no generator is registered then a default
QgsProcessingFeedbackobject will be created.See also
Added in version 4.2.
- Parameters:
generator (Optional[QgsProcessingFeedbackGenerator])
- reportError(self, error: str | None, fatalError: bool)[source]¶
Reports an
errorstring to the widget’s log.If
fatalErrorisTrue, the error prevented the algorithm from executing.- Parameters:
error (Optional[str])
fatalError (bool)
- virtual resetAdditionalGui(self)[source]¶
For subclasses to register their own GUI controls to be reset, ready for another algorithm execution.
- results(self) dict[str, Any][source]¶
Returns the results returned by the algorithm executed.
See also
See also
- Return type:
dict[str, Any]
- virtual runAlgorithm(self)[source]¶
Called when the widget’s algorithm should be run. Must be overridden by subclasses.
- runButton(self) QPushButton | None[source]¶
Returns the widget’s run button.
- Return type:
Optional[QPushButton]
- saveLog(self)[source]¶
Opens a dialog allowing users to save the current log contents.
See also
Added in version 3.2.
- saveLogToFile(self, path: str | None, format: QgsProcessingAlgorithmWidgetBase.LogFormat = QgsProcessingAlgorithmWidgetBase.LogFormat.FormatPlainText)[source]¶
Saves the log contents to a text file (specified by the file
path), in the givenformat.See also
Added in version 3.2.
- Parameters:
path (Optional[str])
format (QgsProcessingAlgorithmWidgetBase.LogFormat = QgsProcessingAlgorithmWidgetBase.LogFormat.FormatPlainText)
- setAlgorithm(self, algorithm: QgsProcessingAlgorithm | None)[source]¶
Sets the
algorithmto run in the widget.Ownership of the algorithm instance is transferred to the widget.
See also
- Parameters:
algorithm (Optional[QgsProcessingAlgorithm])
- setCurrentTask(self, task: QgsProcessingAlgRunnerTask | None)[source]¶
Sets the current
taskrunning in the widget. The task will automatically be started by the widget. Ownership oftaskis transferred to the widget.- Parameters:
task (Optional[QgsProcessingAlgRunnerTask])
- setExecuted(self, executed: bool)[source]¶
Sets whether the algorithm was executed through the widget.
See also
See also
- Parameters:
executed (bool)
- setExecutedAnyResult(self, executedAnyResult: bool)[source]¶
Sets whether the algorithm was executed through the widget (no matter the result).
- Parameters:
executedAnyResult (bool)
- setInfo(self, message: str | None, isError: bool = False, escapeHtml: bool = True, isWarning: bool = False)[source]¶
Displays an info
messagein the widget’s log.- Parameters:
message (Optional[str])
isError (bool = False)
escapeHtml (bool = True)
isWarning (bool = False)
- setLogLevel(self, level: Qgis.ProcessingLogLevel)[source]¶
Sets the logging
levelto use when running algorithms from the widget.See also
Added in version 3.20.
- Parameters:
level (Qgis.ProcessingLogLevel)
- setMainWidget(self, widget: QgsPanelWidget | None)[source]¶
Sets the main
widgetfor the widget, usually a panel for configuring algorithm parameters.See also
- Parameters:
widget (Optional[QgsPanelWidget])
- virtual setParameters(self, values: dict[str | None, Any])[source]¶
Sets the parameter
valuesto show in the widget.Added in version 3.24.
- setPercentage(self, percent: float)[source]¶
Sets the percentage progress for the widget, between 0 and 100.
- Parameters:
percent (float)
- setProgressText(self, text: str | None)[source]¶
Sets a progress text message.
- Parameters:
text (Optional[str])
- setResults(self, results: dict[str | None, Any])[source]¶
Sets the algorithm results.
See also
See also
- tabWidget(self) QTabWidget | None[source]¶
Returns the widget’s tab widget.
- Return type:
Optional[QTabWidget]
- updateRunButtonVisibility(self)[source]¶
Sets visibility for mutually exclusive buttons Run and Change Parameters.