Hi, I have a param.parameterized class, in which I initialized a certain number of params with the self.param._add_parameter() function. It works very well but now I need to link these parameters to some functions in order to refresh the visualization when I change a parameter.
In that case I don’t think I can use the @param.depends decorator since I need to link a parameter to a function of an already instantiated object.
I tried to use the function param.depends(viewer.myfunc,‘myparam’), it changes the attribute dinfo, but the dependence doesn’t work in the resulting panel GUI.
Is there a way to link some parameters and some function of an instantiated object without using the @param.depends() decorator ?
Here is an example :
class testview(param.Parameterized):
check_val=0
def add_parameters(self,k):
for i in range(k):
self.param._add_parameter(f'param{i}',param.Integer(default=0))
def increment_val(self):
self.check_val+=1
return hv.Text(0.5,0.5, str(self.check_val))
viewer = testview()
viewer.add_parameters(3)
pn.Row(pn.Param(viewer.param),viewer.increment_val())
In this example I have now 3 Integer widget and a holoview display of the attribute check_val.
I want to link each param to the increment_val() function, in order to refresh the view when I change the value of a parameter.