panel icon indicating copy to clipboard operation
panel copied to clipboard

Param trigger not working as expected

Open skemp117 opened this issue 10 months ago • 3 comments

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

skemp117 avatar Apr 15 '24 19:04 skemp117

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

skemp117 avatar Apr 15 '24 22:04 skemp117

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

ahuang11 avatar Apr 16 '24 03:04 ahuang11

Thank you for the reply!

skemp117 avatar Apr 17 '24 16:04 skemp117