Can a Python plugin access Paraview's progress bar?

Is there a way for a plugin, i.e., a class that inherits from “VTKPythonAlgorithmBase” to access Paraview’s (status bar) progress bar widget. The class vtkAlgorithm has the methods “SetProgressShiftScale”, “SetProgressText”, etc., for instance. However if you call them from a plugin they seem not to anything. The idea is to provide some interactivity, i.e., progress, while the plugin reads large input files that can take minutes to load. Is there an example consuming these methods (C++ or Python)? Thanks.

Hi @florezg and welcome to ParaView’s discourse !

Yes you can access the progress bar by using using the API you mentioned. Here is an example:

from paraview.util.vtkAlgorithm import (
    VTKPythonAlgorithmBase,
    smproxy,
    smproperty,
    smdomain,
)

from time import sleep

@smproxy.filter(name="Test progress")
@smproperty.input(name="Input") 
@smdomain.datatype( dataTypes=["vtkUnstructuredGrid"],
) 
class TestProgress(VTKPythonAlgorithmBase):
    def __init__(self):
        super().__init__(
            nInputPorts=1, nOutputPorts=1, outputType="vtkUnstructuredGrid"
        )
        self.SetProgressText("Test Progress")

    def RequestData(self, request, inInfo, outInfo):

        # init step takes 10%
        sleep(2)
        self.UpdateProgress(0.1)

        # loop takes 80%, i.e. from 10%->90%
        self.SetProgressShiftScale(0.1,0.9)
        for i in range(10):
          self.UpdateProgress(i/10);
          sleep(1)

        # reset scale
        self.SetProgressShiftScale(0,1.0)
        # final takes 10%
        self.UpdateProgress(1.0)
        sleep(1)

        return 1 

Thanks for the help! It does the trick. Best regards.