[英]Bokeh: How to un-select all the values from multi-select drop down list?
我在 Bokeh 應用程序中有一個 MultiSelect 下拉列表。 我想在我的工作完成后取消選擇所有值。
“全選”也可以做到這一點。
from bokeh.io import show
from bokeh.models import CustomJS, MultiChoice, Button
output_file("multichoice-all-clear.html", title="states")
OPTIONS = ["foo", "bar", "baz", "quux"]
## Define the widgets
buttonAll = Button(label="Select all", button_type="success")
buttonClear = Button(label="Clear selection", button_type="success")
multi_choice = MultiChoice(value=["foo", "baz"], options=OPTIONS)
## Define callbacks/interactivity
multi_choice.js_on_change("value", CustomJS(code="""
console.log('multi_choice: value=' + this.value, this.toString())
"""))
button_callback = CustomJS(
args=dict(s=multi_choice),
code="""
s.value= s.options;
console.log('button: click!', this.toString());
""")
buttonAll.js_on_click(button_callback)
button_callback = CustomJS(
args=dict(s=multi_choice),
code="""
s.value= [];
console.log('button: click!', this.toString());
""")
buttonClear.js_on_click(button_callback)
layout = gridplot([buttonAll, buttonClear,
multi_choice], ncols=1, toolbar_location=None)
show(layout)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.