Requirement is to from a multi select widget to enable users to select from a list of countries, and then have a widget button which, when clicked, runs all the cells below.
from IPython.display import display
w = widgets.SelectMultiple(
description="Select up to five countries",
options=dfCountries['name'].tolist()
)
display(w)
Below is how to do it
from IPython.display import Javascript, display
from ipywidgets import widgets
def run_all(ev):
display(Javascript('IPython.notebook.execute_cells_below()'))
button = widgets.Button(description="Create next input")
button.on_click(run_all)
display(button)
References:
https://stackoverflow.com/questions/32714783/ipython-run-all-cells-below-from-a-widget/32769976#32769976
No comments:
Post a Comment