[QGIS-Developer] Several Processing Plugin Questions

Nyall Dawson nyall.dawson at gmail.com
Thu Jun 28 16:11:23 PDT 2018


On Fri, 29 Jun 2018 at 01:52, C Hamilton <adenaculture at gmail.com> wrote:
>
> 1. For the QgsProcessingAlgorithm you define 'name', 'displayName', 'group', and 'groupId'. The group creates a sub folder within my processing toolbox. What if I don't want a group sub folder within my toolbox. How do I have the algorithm on the first level?

That's not possible in <=3.2. I'm refactoring the toolbox currently,
I'll add support for this for 3.4.

> 2. I am working on this for Shape Tools and not all the tools will be processing algorithms. I would like to be able to call the processing algorithm from my Shape Tools menu. I see no reason to programmatically create two interfaces for the algorithm. How can I launch the processing algorithm from the menu.

Call either

    # populate with parameters you want to show in the dialog, if you
want non-default values
    initial_parameters = {}
    results = processing.execAlgorithmDialog('qgis:buffer', initial_parameters)

Or

    # populate with parameters you want to show in the dialog, if you
want non-default values
    initial_parameters = {}
    dlg =  processing.createAlgorithmDialog('qgis:buffer', initial_parameters)
    # do something with dlg

The difference is that execAlgorithmDialog handles automatically
showing the dialog and return the algorithm results, while
createAlgorithmDialog leaves it up to you to show and execute the
dialog and retrieve the results.

Nyall


More information about the QGIS-Developer mailing list