Sunday 15 September 2019

pyqgis - How to write log message in QGIS's script algorithms GUI tab?


I want to write some log in the log tab of processing algorithm User Interface.


I tried this :



from qgis.core import QgsMessageLog

QgsMessageLog.logMessage("test")

but when I launch the script "test" is not logged.


enter image description here


How to write a log in the processing User Interface ?


the processing guide log's chapter doesn't tell much about writing a log in this tab.


If i use :


from qgis.core import QgsMessageLog

QgsMessageLog.logMessage("test", tag="Processing", level=QgsMessageLog.INFO)

the log result is wrote under the console log panel called "Processing", but not in the processing GUI log tab. enter image description here



Answer



You can do this with global variable progress. see the user manual, processing chapter


progress.setText('Youpi')

Will print 'Youpi' in the processing log.


It supports html formatting:


progress.setText('Youpi')


to print in bold...


progress come also with setPercentage() methods to control the progress bar


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...