Feasibility of Creating a Python-Based Source Plugin in ParaView with Interactive Properties

Hi!
I am trying to make a source plugin using Python. Once the plugin is added to the pipeline browser, I expect it to display a text-box in the Properties panel. When the user enter a valid root-folder path in the text-box, I expect to see a combo-box/drop-down displayed in the same Properties panel populated with all sub-directory names falling under the root-folder I mentioned earlier. Based on the user selection from the combo-box, the source will read a mesh data file from the user selected sub-directory and render it on the screen as a polydata. Is this a feasible thing to do if I consider using Python-based plugins only? I just need a “yes” or “no”.

I don’t think this is possible as the values from a combo box would need to come from a customized vtkSMStringListDomain (I think) and there isn’t a way to do this in Python Algorithm plugins as far as I know.

1 Like

Thank you Cory! Just learned about PythonQtPlugin. Don’t know much about it, but Is that a thing which I can use to help in my case somehow? I just need to present a combobox to the user so that he can pick a subject-folder of choice and finally render the mesh contents in the selected folder to the scene. :slight_smile: If there is no python-based solution, how would you imagine doing this through a C++ plugin?

I’m afraid I don’t know much about PythonQtPlugin or whether it still works.

1 Like

Is that a thing ?

Nothing prevents you to use PythonQt but that is not the right way to do it I’m afraid

1 Like

thank you @mwestphal

@cory.quammen If this is not possible from Python, is there a way to accomplish this from c++?
I am currently looking into developing a source plugin that dynamically changes its properties with respect to the loaded source.
For example: Changing the label of a property or its range minimum or maximum value or the default value of the corresponding slider.
An estimate if this would be possible is greatly appreciated!

Hi @Woltan Now I feel confident to say “YES” to my original problem and another “YES” to your problem.

Hi @Reshm_R_S,
those are good new. Could you please elaborate on your answer? Could you maybe show in a minimum working example of how this is accomplished?
The code below is a simple source plugin template which currently doesn’t do anything. Could you show how to modify the parameter param1 on the fly, after a file is read?
I would also be very much interested in adding new parameters like param2 to the plugin, after a file is read.

from typing import Optional

from paraview.detail.pythonalgorithm import smproxy, smproperty, smdomain
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from vtkmodules.vtkCommonDataModel import vtkPolyData
from vtkmodules.vtkFiltersSources import vtkConeSource


@smproxy.source(name="reader", label="Reader")
class NavDesign(VTKPythonAlgorithmBase):
    def __init__(self):
        super().__init__(nInputPorts=0)

        self._source = vtkConeSource()

    def RequestData(self, request, inInfo, outInfo):
        self._source.Update()

        output = vtkPolyData.GetData(outInfo, 0)
        output.ShallowCopy(self._source.GetOutput())

        return 1

    @smproperty.stringvector(name="Param1", number_of_elements="1")
    def param1(self, value: Optional[str]):
        self.Modified()