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

**URL:** https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443
**Category:** ParaView Support
**Created:** [April 19, 2024, 5:04pm UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443 "2024-04-19T17:04:47Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Reshm\_R\_S](https://discourse.paraview.org/user_avatar/discourse.paraview.org/reshm_r_s/32/12131_2.png) [@Reshm\_R\_S](https://discourse.paraview.org/u/Reshm_R_S)
#### Post date: [April 19, 2024, 5:04pm UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/1 "2024-04-19T17:04:47Z")

</div>

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”.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [April 19, 2024, 6:08pm UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/2 "2024-04-19T18:08:20Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Reshm\_R\_S](https://discourse.paraview.org/user_avatar/discourse.paraview.org/reshm_r_s/32/12131_2.png) [@Reshm\_R\_S](https://discourse.paraview.org/u/Reshm_R_S)
#### Post date: [April 19, 2024, 7:05pm UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/3 "2024-04-19T19:05:44Z")

</div>

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. 🙂 If there is no python-based solution, how would you imagine doing this through a C++ plugin?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [April 19, 2024, 10:46pm UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/4 "2024-04-19T22:46:21Z")

</div>

> [@Reshm\_R\_S](#):
>
> PythonQtPlugin

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

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 22, 2024, 7:21am UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/5 "2024-04-22T07:21:46Z")

</div>

> [@Reshm\_R\_S](#):
>
> Just learned about PythonQtPlugin.

Is that a thing ?

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

---

<div class="post-metadata">

### Author: ![Reshm\_R\_S](https://discourse.paraview.org/user_avatar/discourse.paraview.org/reshm_r_s/32/12131_2.png) [@Reshm\_R\_S](https://discourse.paraview.org/u/Reshm_R_S)
#### Post date: [April 22, 2024, 9:11am UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/6 "2024-04-22T09:11:08Z")

</div>

thank you @mwestphal

---

<div class="post-metadata">

### Author: ![Woltan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/woltan/32/14248_2.png) [@Woltan](https://discourse.paraview.org/u/Woltan)
#### Post date: [April 25, 2024, 11:16am UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/7 "2024-04-25T11:16:09Z")

</div>

@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!

---

<div class="post-metadata">

### Author: ![Reshm\_R\_S](https://discourse.paraview.org/user_avatar/discourse.paraview.org/reshm_r_s/32/12131_2.png) [@Reshm\_R\_S](https://discourse.paraview.org/u/Reshm_R_S)
#### Post date: [April 28, 2024, 1:01pm UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/9 "2024-04-28T13:01:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Woltan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/woltan/32/14248_2.png) [@Woltan](https://discourse.paraview.org/u/Woltan)
#### Post date: [April 30, 2024, 4:42am UTC](https://discourse.paraview.org/t/feasibility-of-creating-a-python-based-source-plugin-in-paraview-with-interactive-properties/14443/10 "2024-04-30T04:42:29Z")

</div>

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.

```python
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()

```
