Search code examples
python-3.xbokehmulti-select

Bokeh: How to un-select all the values from multi-select drop down list?


I have a MultiSelect drop-down list in Bokeh application. I want to un-select all the values after my work is done.


Solution

  • There is no UI interaction the widget itself offers as far as I know to clear it. You could make a button with a CustomJS callback that resets the MultiSelect values:

    select = MultiSelect(options=["First", "Second", "Third"])
    button = Button(label="clear")
    
    callback = CustomJS(args=dict(s=select), code="s.value=[]")
    button.js_on_event('button_click', callback)
    

    Before clicking the button:

    enter image description here

    After clicking the button:

    enter image description here