In your code params.widgets['k']
returns the widget class that you’ve defined in pn.Param(...)
. You need to modify the widget instance, to which you can get a handle on with params.layout[2]
(it’s the third widget, after the title and the dataset widget).
@pn.depends(dataset=data_params.param.dataset, watch=True)
def show_widgets(dataset):
print('Hey', dataset)
if dataset == 'Data 1':
params.layout[2].visible = True
else:
params.layout[2].visible = False