panel
panel copied to clipboard
Param trigger not working as expected
ALL software version info
panel 1.4.1 Python 3.11.5
Description of expected behavior and the observed behavior
Expect param trigger to update frontend with new values for the triggered parameter
Complete, minimal, self-contained example code that reproduces the issue
import panel as pn
pn.extension()
add_data_button = pn.widgets.MenuButton(name ='Add Selected Data', items=['REMOVE'], width_policy = 'max', align='end', button_type = 'primary')
def change(_):
print('here')
add_data_button.items = ['1','2']
add_data_button.param.trigger('items')
change_button = pn.widgets.Button(name = 'change items')
change_button.on_click(change)
layout = pn.layout.Column(add_data_button, change_button)
layout.servable()
Stack traceback and/or browser JavaScript console output
Screenshots or screencasts of the bug in action
- [ ] I may be interested in making a pull request to address this
A workaround is putting the add_data_button in a container like a Column, and generating a new add_data_button, then calling trigger on the objects property of the column
Thanks for reporting! I don't think it's an issue with param.trigger
; instead I think this might be an upstream Bokeh issue since I think Panel simply wraps MenuButton https://github.com/holoviz/panel/blob/main/panel/widgets/button.py#L324-L335
https://docs.bokeh.org/en/latest/docs/user_guide/interaction/widgets.html#dropdown
Thank you for the reply!