Is it possible to update options + value at the same time for param class?

in panel, there’s widget.set_param(objects=[], value=[])

but in param

        self.param["value"].objects = values
        self.value= values[-1]

Is there a method to do it simultaneously

I’m curious about what reason you have to need to do so simultaneously?

I find myself doing this a lot:

values = something.get_values()
self.param["value"].objects = values
if self.value is not None and values:
    self.value = value[0]

In situations where widgets check if there are new values available, and if the widget has not been set yet, it defaults to the first (or last) option.

I think once options is updated to new values, value is also updated to the first available value in the list of options, which triggers a separate call once, but I actually want it to default to the last available value in the list of options, so I set it, and that triggers the separate call again, so by setting it together, I think it batches it and doesn’t duplicate the calls? I could be wrong

I guess then the original value is not in the new values?
Is it an option to invert the order of your values such that it will set the value you want by default?

1 Like

Correct, the original value is not in the new values. If I invert the order of the values, the discrete slider is not intuitive in my use case, but thanks for your feedback!

I think I may want to experiment with this method:
https://param.holoviz.org/reference.html#param.parameterized.batch_watch

Oh thats a good one i need that as well :slight_smile: