3

I would like to programmatically show a processing algorithm dialog from Python. I gived a look to processing toolbox and I found that this is possible importing and instantiating the class AlgorithmDialog gui/processingToolbox.py

from processing.gui.AlgorithmDialog import AlgorithmDialog
from qgis.core import QgsApplication

alg = QgsApplication.processingRegistry().algorithmById('qgis:extractbyattribute')
dlg = AlgorithmDialog(alg, False, iface.mainWindow())
dlg.show()
dlg.exec_()

This opens algorithm dialog and let me perform processing computations but once closed the dialog window QGIS become unstable and crash without any message interacting with the user interface.

What am I doing wrong? Is there a method to do this in other way?

1 Answer 1

6

You have another function for doing this:

from processing import execAlgorithmDialog

params = {}  # A dictionary to load some default value in the dialog
execAlgorithmDialog('qgis:extractbyattribute', params)
2
  • Great. Very handy solution. Jan 24, 2020 at 23:28
  • 1
    the method returns the results dict so you can perform further action like styling renaming etc.. 'results = execAlgorithmDialog('qgis:extractbyattribute', params)' Jan 29, 2020 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.