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
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)
-
Great. Very handy solution.Enrico Ferreguti– Enrico Ferreguti2020年01月24日 23:28:54 +00:00Commented Jan 24, 2020 at 23:28
-
1the method returns the results dict so you can perform further action like styling renaming etc.. 'results = execAlgorithmDialog('qgis:extractbyattribute', params)'Enrico Ferreguti– Enrico Ferreguti2020年01月29日 11:09:09 +00:00Commented Jan 29, 2020 at 11:09