I try to use progress.setPercentage(i/pages) in PyQGIS processing.
I tried to give integers, floats between 0 to 100.
Example:
percent = 33 percent = 33.3 percent = 0.33 progress.setPercentage(percent) Nothing appears in the progress bar and no crash.
progress.setText("Blablaba") is working
The script
##Extract then join WS and attributes=name ##Scripts utilisateur=group ##B1_column_position=number 1 ##SQL_query_file=file ##File_name=string extrWS_geom.shp # https://medspx.fr/blog/Qgis/verify_oracle_geoalgorithm/ to install cx_oracle import cx_Oracle from qgis.core import * from qgis.core import QgsProject from PyQt4.QtCore import QFileInfo from PyQt4.QtCore import QVariant import os import datetime ... for i in range(pages): progress.setPercentage(i/pages*100) print("pagination : " + str(i)) rage = i*1000 print(rage) attributesList1000 = convertedDatesattributesList[rage:rage+1000] geometriesLayer = getGeoms(writeGeomquery(attributesList1000)) for attr in attributesList1000 : writer.addFeature(joinGeombyID_WS(attr, geometriesLayer)) ... QGIS documentation:
If your algorithm takes a long time to process, it is a good idea to inform the user. You have a global named progress available, with two possible methods: setText(text) and setPercentage(percent) to modify the progress text and the progress bar.
Several examples are provided. Please check them to see real examples of how to create algorithms using the processing framework classes. You can right-click on any script algorithm and select Edit script to edit its code or just to see it.
progress.setValue(percent)?progress.setPercentage((i/float(pages))*100)?