With this:
import param
import panel as pn
pn.extension()
class Test(param.Parameterized):
a = param.Selector(default=1, objects=[1, 2, 3])
widgets = pn.Param(Test())
Instead of outputting:
pn.widgets.Select(name='A', options=[1, 2, 3])
Is it possible to output:
pn.widgets.Select(name='A', groups={"One": [1], "Two": [2], "Three": [3]})
Forcing options = []
works.
import param
import panel as pn
pn.extension()
class Test(param.Parameterized):
a = param.Selector(default=1, objects=[1, 2, 3])
test = Test()
pn.Param(
test,
widgets={
"a": {
"type": pn.widgets.Select,
"groups": {"Group 1": [1], "Group 2": [2], "Group 3": [3]},
"options": [],
}
},
)
jbednar
September 18, 2023, 8:21pm
3
For reference for anyone else reading this, adding string names can be achieved much more simply using a dictionary rather than a list for the objects:
But I assume that in Andrew’s real example there were multiple items per group, for which I believe his solution is the right approach.
1 Like
Right in the actual case I needed to use groups. Thanks for clarifying the other case.