holoviz/panel
View on GitHubFeature Request: Access label of "select-like" elements through property
Open
#6,274 opened on Jan 26, 2024
good first issuetype: enhancement
Repository metrics
- Stars
- (5,722 stars)
- PR merge metrics
- (PR metrics pending)
Description
When creating a select-like element with different values and labels, we can only access the value directly, but not the label.
Current way
import panel as pn
pn.extension()
radio = pn.widgets.RadioBoxGroup(
name="MultiSelect Example",
options={"one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6},
value=3,
)
radio
radio.value
Current workaround
def get_selected_label(radio_group):
return list(radio_group.options.keys())[list(radio_group.options.values()).index(radio_group.value)]
selected_label = get_selected_label(radio)
print(selected_label)
Proposed solution
What I want is to access the selected label through a property.
Have a property such as
radio.label
That acts the same as the get_selected_label function above.