[QGIS-Developer] createAlgorithmDialog in Processing script (within plugin)

matteo matteo.ghetta at gmail.com
Fri Aug 12 05:15:48 PDT 2022


Hi Germàn,


> If you want and if you have the time, we could have a look at this issue 
> at the QGIS Contributors Meeting in Firenze :)

that's great, see you very soon!

Cheers!

Matteo
> 
> Regards!
> 
> Germán
> 
> 
> El lun, 1 ago 2022 a las 17:07, matteo (<matteo.ghetta at gmail.com 
> <mailto:matteo.ghetta at gmail.com>>) escribió:
> 
>     Hi German,
> 
>     yes in your way it is working. But what if you try not with the
>     algorithm/model id, but with an instance of the algorithm?
> 
>     In the docs I read "Either an instance of an algorithm, or an
>     algorithm's ID", therefore I'm trying to set up an instance of my
>     algorithm and then passing it to the method
> 
>     Cheers and thanks
> 
>     Matteo
> 
>     On 8/1/22 16:17, Germán Carrillo wrote:
>      > Hi Matteo,
>      >
>      > I've been successfully using /execAlgorithmDialog()/ instead [0]:
>      >
>      > /processing.execAlgorithmDialog("my_provider:my_algorithm", params)/
>      >
>      > where, /params/ is a dict with the pre-filled values you have.
>     You can
>      > see an example at [1].
>      >
>      > Regards,
>      >
>      > Germán
>      > -----------
>      > [0]
>      >
>     https://github.com/qgis/QGIS/blob/2d1aa68f0d044f2aced7ebeca8d2fa6b754ac970/python/plugins/processing/tools/general.py#L185 <https://github.com/qgis/QGIS/blob/2d1aa68f0d044f2aced7ebeca8d2fa6b754ac970/python/plugins/processing/tools/general.py#L185> <https://github.com/qgis/QGIS/blob/2d1aa68f0d044f2aced7ebeca8d2fa6b754ac970/python/plugins/processing/tools/general.py#L185 <https://github.com/qgis/QGIS/blob/2d1aa68f0d044f2aced7ebeca8d2fa6b754ac970/python/plugins/processing/tools/general.py#L185>>
>      > [1]
>      >
>     https://github.com/SwissTierrasColombia/LADM-COL-Add-on-Ambiente/blob/master/ladm_col_environment_add_on.py#L140 <https://github.com/SwissTierrasColombia/LADM-COL-Add-on-Ambiente/blob/master/ladm_col_environment_add_on.py#L140> <https://github.com/SwissTierrasColombia/LADM-COL-Add-on-Ambiente/blob/master/ladm_col_environment_add_on.py#L140 <https://github.com/SwissTierrasColombia/LADM-COL-Add-on-Ambiente/blob/master/ladm_col_environment_add_on.py#L140>>
>      >
>      >
>      > El lun, 1 ago 2022 a las 15:23, matteo via QGIS-Developer
>      > (<qgis-developer at lists.osgeo.org
>     <mailto:qgis-developer at lists.osgeo.org>
>      > <mailto:qgis-developer at lists.osgeo.org
>     <mailto:qgis-developer at lists.osgeo.org>>>) escribió:
>      >
>      >     Hi all,
>      >
>      >     I've a set of custom processing scripts within a plugin (that
>     is both
>      >     "normal" and processing provider plugin).
>      >
>      >     I'm trying to executing the dialog of these algorithm from
>     one of the
>      >     main plugin file. I found the
>     processing.createAlgorithmDialog [0], but
>      >     it is constantly crashing when I'm passing the instance of the
>      >     algorithm:
>      >
>      >     my_alg = MyCustomAlg()
>      >     my_dialog = my_alg.createAlgorithmDialog(custom_dict)
>      >
>      >     ## crash here
>      >
>      >     Thinking it was a problem of the threads I also tried to
>     overwrite the
>      >     `flag` method in the algorithm by setting also
>      >     QgsProcessingAlgorithm.FlagNoThreading but with the same results.
>      >
>      >     I know I can run the processing algorithm with
>     processing.run(....) but
>      >     I need to open the dialog pre-filled with custom parameters
>     and to get
>      >     also some other outputs besides the standard ones (like the
>      >     QgsFeatureSink path)
>      >
>      >     Thanks for any suggestion
>      >
>      >     Cheers
>      >
>      >     Matteo
>      >
>      >
>      >     [0]
>      >
>     https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tools/general.py#L155 <https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tools/general.py#L155> <https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tools/general.py#L155 <https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tools/general.py#L155>>
>      >
>      >     _______________________________________________
>      >     QGIS-Developer mailing list
>      > QGIS-Developer at lists.osgeo.org
>     <mailto:QGIS-Developer at lists.osgeo.org>
>     <mailto:QGIS-Developer at lists.osgeo.org
>     <mailto:QGIS-Developer at lists.osgeo.org>>
>      >     List info:
>     https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>      >     <https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>>
>      >     Unsubscribe:
>     https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>      >     <https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>>
>      >
>      >
>      >
>      > --
>      > -----------
>      >     |\__
>      > (:>__)(
>      >     |/
>      > Soluciones Geoinformáticas Libres
>      > http://geotux.tuxfamily.org/ <http://geotux.tuxfamily.org/>
>     <http://geotux.tuxfamily.org/ <http://geotux.tuxfamily.org/>>
>      > https://twitter.com/GeoTux2 <https://twitter.com/GeoTux2>
>     <http://twitter.com/GeoTux2 <http://twitter.com/GeoTux2>>
>      >
>      > <http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo
>     <http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo>>
> 
> 
> 
> -- 
> -----------
>     |\__
> (:>__)(
>     |/
> Soluciones Geoinformáticas Libres
> http://geotux.tuxfamily.org/ <http://geotux.tuxfamily.org/>
> https://twitter.com/GeoTux2 <http://twitter.com/GeoTux2>
> 
> <http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo>


More information about the QGIS-Developer mailing list