Re: [QGIS-Developer] process bar in processing algs

2021-07-20 Thread pierluigi de rosa
Thanks guys,

I solved my problem

In particular it was the feedback.progressChanged.connect suggested by
German the missing part.
Cheers
Pierluigi

Il giorno mar 20 lug 2021 alle ore 15:20 Germán Carrillo <
carrillo.ger...@gmail.com> ha scritto:

> Hi Pierluigi,
>
>
> you need to create your own *feedback* object and connect its
> *progressChanged* SIGNAL to your progressbar's *setValue* SLOT, in this
> way:
>
>
> feedback = QgsProcessingFeedback()
> feedback.progressChanged.connect(progressBarGrid.setValue)
>
> params_creategrid = {
> # Set key-value parameters
> }
> result_grid = processing.run("native:creategrid", params_creategrid,
> feedback=feedback)
>
>
> Source: https://gis.stackexchange.com/a/348588/4972
>
>
> Regards,
>
> Germán
>
> El mar, 20 jul 2021 a las 4:52, matteo ()
> escribió:
>
>> Hi Pierluigi,
>>
>>
>> > can you please explain me better?
>> > I have self plugin that in particular part use this code
>> >
>> > result_grid = processing.run("native:creategrid", params_creategrid)
>>
>> as explained by Prem, if you want to add the progress when you call a
>> "native" algorithm of QGIS within your algorithm, then you can pass to
>> the algorithm parameters:
>>
>> result_grid = processing.run("native:creategrid", params_creategrid,
>> context=context, feedback=feedback)
>>
>> be aware also at the `is_child` parameter. Have a look at the example:
>>
>>
>> https://docs.qgis.org/3.4/en/docs/user_manual/processing/scripts.html#extending-qgsprocessingalgorithm
>>
>> if you want to add steps to the progressBar with your logic then you can
>> use feedback.setProgress(number) to fill the progress bar. Have a look
>> at the template script and you will find a fine usage
>>
>> Hope this helps
>>
>> Matteo
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
>
> --
> ---
>|\__
> (:>__)(
>|/
> Soluciones Geoinformáticas Libres
> http://geotux.tuxfamily.org/
> https://twitter.com/GeoTux2 
>
>

-- 
Ing. Pierluigi De Rosa (PhD in Earth Science)
Contract Professor of Geographic Information System at University of Perugia
cel: 3497558268 / fax: 075 7823038
skype: pierluigi.derosa
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] process bar in processing algs

2021-07-20 Thread Germán Carrillo
Hi Pierluigi,


you need to create your own *feedback* object and connect its
*progressChanged* SIGNAL to your progressbar's *setValue* SLOT, in this way:


feedback = QgsProcessingFeedback()
feedback.progressChanged.connect(progressBarGrid.setValue)

params_creategrid = {
# Set key-value parameters
}
result_grid = processing.run("native:creategrid", params_creategrid,
feedback=feedback)


Source: https://gis.stackexchange.com/a/348588/4972


Regards,

Germán

El mar, 20 jul 2021 a las 4:52, matteo () escribió:

> Hi Pierluigi,
>
>
> > can you please explain me better?
> > I have self plugin that in particular part use this code
> >
> > result_grid = processing.run("native:creategrid", params_creategrid)
>
> as explained by Prem, if you want to add the progress when you call a
> "native" algorithm of QGIS within your algorithm, then you can pass to
> the algorithm parameters:
>
> result_grid = processing.run("native:creategrid", params_creategrid,
> context=context, feedback=feedback)
>
> be aware also at the `is_child` parameter. Have a look at the example:
>
>
> https://docs.qgis.org/3.4/en/docs/user_manual/processing/scripts.html#extending-qgsprocessingalgorithm
>
> if you want to add steps to the progressBar with your logic then you can
> use feedback.setProgress(number) to fill the progress bar. Have a look
> at the template script and you will find a fine usage
>
> Hope this helps
>
> Matteo
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>


-- 
---
   |\__
(:>__)(
   |/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
https://twitter.com/GeoTux2 
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] process bar in processing algs

2021-07-20 Thread matteo

Hi Pierluigi,



can you please explain me better?
I have self plugin that in particular part use this code

result_grid = processing.run("native:creategrid", params_creategrid)


as explained by Prem, if you want to add the progress when you call a 
"native" algorithm of QGIS within your algorithm, then you can pass to 
the algorithm parameters:


result_grid = processing.run("native:creategrid", params_creategrid, 
context=context, feedback=feedback)


be aware also at the `is_child` parameter. Have a look at the example:

https://docs.qgis.org/3.4/en/docs/user_manual/processing/scripts.html#extending-qgsprocessingalgorithm

if you want to add steps to the progressBar with your logic then you can 
use feedback.setProgress(number) to fill the progress bar. Have a look 
at the template script and you will find a fine usage


Hope this helps

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] process bar in processing algs

2021-07-20 Thread Prem Kumar
Hi Mate,

Every processing tool has to implement its business logic in
processAlgorithm() function and it has below syntax.

*def processAlgorithm(self, parameters, context, feedback):*

One of the input parameters is feedback and this as a parameter variable
should be given to the *processing.run()* function as shown below.

Hope, this helps.

result_grid = processing.run("native:creategrid", params_creategrid*,
context=context, feedback=feedback*)


On Tue, Jul 20, 2021 at 2:45 PM pierluigi de rosa <
pierluigi.der...@gmail.com> wrote:

> Hi Matteo,
> can you please explain me better?
> I have self plugin that in particular part use this code
>
> result_grid = processing.run("native:creategrid", params_creategrid)
>
> But I would like to use note the progressBar of processing but a personal
> bar in the QDialog
>
> It is possible?
> P
>
> Il giorno mar 20 lug 2021 alle ore 11:01 matteo 
> ha scritto:
>
>> Hi Pierluigi,
>>
>> you can fill the progressBar of the Processing algorithm with
>> feedback.setProgress(integer).
>>
>> Hope this helps
>>
>> Matteo
>>
>
>
> --
> Ing. Pierluigi De Rosa (PhD in Earth Science)
> Contract Professor of Geographic Information System at University of
> Perugia
> cel: 3497558268 / fax: 075 7823038
> skype: pierluigi.derosa
> ___
> QGIS-Developer mailing list
> QGIS-Developer@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@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] process bar in processing algs

2021-07-20 Thread pierluigi de rosa
Hi Matteo,
can you please explain me better?
I have self plugin that in particular part use this code

result_grid = processing.run("native:creategrid", params_creategrid)

But I would like to use note the progressBar of processing but a personal
bar in the QDialog

It is possible?
P

Il giorno mar 20 lug 2021 alle ore 11:01 matteo 
ha scritto:

> Hi Pierluigi,
>
> you can fill the progressBar of the Processing algorithm with
> feedback.setProgress(integer).
>
> Hope this helps
>
> Matteo
>


-- 
Ing. Pierluigi De Rosa (PhD in Earth Science)
Contract Professor of Geographic Information System at University of Perugia
cel: 3497558268 / fax: 075 7823038
skype: pierluigi.derosa
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] process bar in processing algs

2021-07-20 Thread matteo

Hi Pierluigi,

you can fill the progressBar of the Processing algorithm with 
feedback.setProgress(integer).


Hope this helps

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


[QGIS-Developer] process bar in processing algs

2021-07-20 Thread pierluigi de rosa
Dear User,
I have a plugin that call a processing alghoritm
I would like to communicate to the user with  a progress bar

below my code:

# native:creategrid
params_creategrid = {
'CRS': crs_layer,
'EXTENT': extent_coords,
'HOVERLAY': 0,
'HSPACING': resolution,
'OUTPUT': 'memory:',
'TYPE': 0,
'VOVERLAY': 0,
'VSPACING': resolution
}

result_grid = processing.run("native:creategrid", params_creategrid)
grid_output = result_grid['OUTPUT']

I would like to show a progressbar in my QprogressBar
called progressBarGrid.
Thanks for your help
Pierluigi
-- 
Ing. Pierluigi De Rosa (PhD in Earth Science)
Contract Professor of Geographic Information System at University of Perugia
cel: 3497558268 / fax: 075 7823038
skype: pierluigi.derosa
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer