# vtkPythonAlgorithm dynamic UI

**URL:** https://discourse.paraview.org/t/vtkpythonalgorithm-dynamic-ui/9011
**Category:** Development
**Tags:** python
**Created:** [February 18, 2022, 1:16pm UTC](https://discourse.paraview.org/t/vtkpythonalgorithm-dynamic-ui/9011 "2022-02-18T13:16:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lou75](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/aca169/32.png) [@lou75](https://discourse.paraview.org/u/lou75)
#### Post date: [February 18, 2022, 1:16pm UTC](https://discourse.paraview.org/t/vtkpythonalgorithm-dynamic-ui/9011/1 "2022-02-18T13:16:33Z")

</div>

Hello,  
is it possible to creat a dynamic UI with the vtkPythonAlgorithm filter model ?

example, having in my python plugin UI multiple “range value slider”, their number depending on the loaded data.

Thanks for help !

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 21, 2022, 8:44am UTC](https://discourse.paraview.org/t/vtkpythonalgorithm-dynamic-ui/9011/2 "2022-02-21T08:44:24Z")

</div>

I do not think so.

A widget is the UI to control a given property of your filter, and those are statically defined. Some widget can have repeatable entries (example: table where user can add/delete rows at runtime) but nothing like that with sliders.

What are you trying to achieve exactly ?

---

<div class="post-metadata">

### Author: ![lou75](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/aca169/32.png) [@lou75](https://discourse.paraview.org/u/lou75)
#### Post date: [February 21, 2022, 11:00am UTC](https://discourse.paraview.org/t/vtkpythonalgorithm-dynamic-ui/9011/3 "2022-02-21T11:00:39Z")

</div>

Hello, thanks for your clear answer,

for my problem, i need to recompose a field from several fields (the number is variable), and for this recomposition i need one scalar per field,  
In qt or another UI API it was simple since widgets are objects and can be created at run time dynamicly, but here they are defined with a decorator. I try to add a function to the instantiated object on the filter constructor with the \_\_ get\_\_.(self) method, I got no error message but the widget did not appear on the panel’ :

@smproperty.intvector(name=“ThetaResolution”, default\_values=16)  
def SetThetaResolution(self, x):  
\_\_\_self.Theta=x  
\_\_\_self.Modified()  
self.SetThetaResolution=SetThetaResolution.\_\_get \_\_(self)

Another solution is to have a (smproperty.stringvector) to list the fields names and one slider, so I can assign the input value to the selected field, but I found that I can’t get informations about the input data before RequestData is called.  
BR

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 21, 2022, 11:42am UTC](https://discourse.paraview.org/t/vtkpythonalgorithm-dynamic-ui/9011/4 "2022-02-21T11:42:56Z")

</div>

For such thing, ParaView only provides table-based widget, still no slider. You will not be able to add property and corresponding widgets at runtime.

## First option: only values and manual setup

if arrays order is well known, you can add `repeatable_command="1"` in the `intvector` decorator. You will have a 1-column table, and user can add / remove rows at runtime and manually specify values. See [this example](https://gitlab.kitware.com/paraview/paraview/-/blob/f8f38a28af6451cef25ee2dcf9a65761c3d80eef/Remoting/Application/Resources/filters_filterscore.xml#L258)

 ![slice](https://discourse.paraview.org/uploads/default/original/2X/2/2c4cbdff6c248235070191b67a9c3eed357544ed.png)

## Second option: array name and values, one entry per array

You should define your property as a stringvector, with two string elements per command.  
You can init this table with array names with the appropriate domain, see [this example](https://gitlab.kitware.com/paraview/paraview/-/blob/f8f38a28af6451cef25ee2dcf9a65761c3d80eef/Remoting/Application/Resources/filters_filterscore.xml#L2234)

 ![rename](https://discourse.paraview.org/uploads/default/original/2X/7/788db9a63d4d78e844d4833d891f1052b49496a4.png)  
Many drawbacks with this one: second column is named “New Name” and is init with array names…

---

<div class="post-metadata">

### Author: ![lou75](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/aca169/32.png) [@lou75](https://discourse.paraview.org/u/lou75)
#### Post date: [February 21, 2022, 11:54am UTC](https://discourse.paraview.org/t/vtkpythonalgorithm-dynamic-ui/9011/5 "2022-02-21T11:54:21Z")

</div>

thanks for your advice
