I am new to panel and I am trying to link this header with selectable buttons to a changing dropdown menu’s. I saw in the documentation the .link function but I am not sure if that’s applicable here. My code is throwing no error, just not properly changing the dropdown.
import panel as pn
import param
class DropdownMenus(param.Parameterized):
header = param.ObjectSelector(objects=['Option 1', 'Option 2', 'Option 3'], default='Option 1', doc="Header")
def view(self):
header = pn.widgets.RadioButtonGroup(name='Header', value=self.header, options=['Option 1', 'Option 2', 'Option 3'], width=100)
if self.header == 'Option 1':
dropdown = pn.widgets.Select(name='Dropdown 1', options=['Option 1.1', 'Option 1.2', 'Option 1.3'], width=100)
elif self.header == 'Option 2':
dropdown = pn.widgets.Select(name='Dropdown 2', options=['Option 2.1', 'Option 2.2', 'Option 2.3'], width=100)
else:
dropdown = pn.widgets.Select(name='Dropdown 3', options=['Option 3.1', 'Option 3.2', 'Option 3.3'], width=100)
header.param.watch(self._update_header, 'value')
return pn.Column(header, dropdown)
def _update_header(self, event):
self.header = event.new
self.param.trigger('header')
DropdownMenus().view()