This gist is forked from pbugnion's great work on building a searchable multi-checkbox using ipywidgets. You can find that work in this gist.
This version adds compatability with Jupyter Widgets' interactive_output()
function, and also makes it easier to see which elements were selected by sorting them to the top. It also makes a few small changes to enable this to work in Jupyter Lab.
import ipywidgets as wid
options_dict = {
x: wid.Checkbox(
description=x,
value=False,
style={"description_width":"0px"}
) for x in ['hello','world']
}
ui = multi_checkbox_widget(options_dict)
out = wid.interactive_output(f, options_dict)
display(wid.HBox([ui, out]))
To get the selected options:
selected_options = [widget.description for widget in ui.children[1].children if widget.value]