[QGIS-Developer] How to open a QGIS prococessing algorithm dialog in python?

DelazJ delazj at gmail.com
Mon Jan 27 01:33:42 PST 2020


Hi,

I have the same needs and I can't find any of these methods in the docs,
neither in https://qgis.org/api/ nor https://qgis.org/pyqgis/master/
Am I missing something?

Regards,
Harrissou

Le lun. 27 janv. 2020 à 07:34, Nyall Dawson <nyall.dawson at gmail.com> a
écrit :

> On Sat, 25 Jan 2020 at 01:43, Enrico Ferreguti <enricofer at gmail.com>
> wrote:
> >
> > Hi QGIS developers,
> >
> > I would like to programmatically show a processing algoritm 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][1]
> >
> >     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 instable 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?
>
> Yep - there's a built in method which does this for you.
>
> You want either
>
> from qgis.processing import createAlgorithmDialog
> dlg = createAlgorithmDialog('qgis:extractbyattribute', parameters={})
> dlg.exec_()
>
> OR
>
> from qgis.processing import execAlgorithmDialog
> results = execAlgorithmDialog('qgis:extractbyattribute', parameters={})
>
> (check the docs for each for the full details)
>
> In general, try to avoid any "from processing.* " imports -- those are
> all internal details and not considered stable API. Anything in
> "qgis.processing" IS stable and is public API, designed for external
> use.
>
> Nyall
>
>
> >
> > I just posted the question on StackExchange:
> https://gis.stackexchange.com/questions/348542/open-qgis-prococessing-algorithm-dialog-with-python
> >
> > Thanks in advance.
> > Enrico Ferreguti.
> >
> >   [1]:
> https://github.com/qgis/QGIS/blob/276a31439eb95f9cdb1053a6ae2dba3f19fbcece/python/plugins/processing/gui/ProcessingToolbox.py#L262
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200127/5fc61476/attachment.html>


More information about the QGIS-Developer mailing list