I have a parameterized class that is going to create a variable number of parameters, depending on what the user is going to pass in. Is there a way to execute the update only when the mouse up event fires?
Let’s consider the following example:
import param
import panel as pn
class MyClass(param.Parameterized):
def __init__(self, parameters, **kwargs):
super().__init__(**kwargs)
self.mapping = {}
# create and attach the params to the class
for i, (k, v) in enumerate(parameters.items()):
# TODO: using a private method: not the smartest thing to do
self.param._add_parameter("dyn_param_{}".format(i), v)
self.mapping[k] = "dyn_param_{}".format(i)
def update(self):
out = []
for k, v in self.mapping.items():
out.append("{} = {}".format(k, getattr(self, v)))
return ", ".join(out)
def show(self):
return pn.Column(self.param, self.update)
m = MyClass({
"a": param.Integer(default=300, softbounds=(100, 500), label="a"),
"b": param.Number(default=1, softbounds=(0.4, 15), label="b"),
})
m.show()
Here, I passed in two parameters, which will be rendered as sliders. Whenever I move a slider, the event will start an update. In this simple case, the output shows the values of the sliders as I moved them.
However, I would like the (automatically) generated sliders (or any other control) to only start the update when the mouse up event occurs. Is it even possible?