import panel as pn
pn.extension()
radio = pn.widgets.CheckButtonGroup(options=["a", "b", "none"])
radio.jscallback(value="""
var last_index = source.labels.length - 1;
if (last_index in source.active) {
source.active = [last_index]
}
""")
radio
I am unsure how to implement the latter part
In python, but it’d be nice if there’s a Javascript equivalent
import panel as pn
pn.extension()
def either_active(event):
print(event.new)
if len(event.new) > 1 and "none" in event.old:
event.obj.value = [value for value in event.new if value != "none"]
elif "none" in event.new:
event.obj.value = ["none"]
radio = pn.widgets.CheckButtonGroup(options=["a", "b", "none"])
radio.param.watch(either_active, "value")
radio