我正在尝试使用多选小部件来使用户能够从国家/地区列表中进行选择,然后有一个小部件按钮,当单击该按钮时,它会运行下面的所有单元格.
这会显示列表.
from IPython.display import display
w = widgets.SelectMultiple(
description="Select up to five countries",
options=dfCountries['name'].tolist()
)
display(w)
Run Code Online (Sandbox Code Playgroud)
我想要这样的东西运行下面的所有单元格:
def run_all(button):
get_ipython().run_cell()
button = widgets.Button(description="Create next input")
button.on_click(run_all)
display(button)
Run Code Online (Sandbox Code Playgroud)
但我找不到"运行下面所有细胞的钩子"
谢谢
我有一个可以过夜运行的笔记本,可以打印出一堆东西,包括图像等。我想以编程方式保存此输出(可能以一定的时间间隔)。我还想保存运行的代码。在 Jupyter 笔记本中,您可以执行以下操作:
from IPython.display import display, Javascript
display(Javascript('IPython.notebook.save_checkpoint();'))
# causes the current .ipynb file to save itself (same as hitting CTRL+s)
Run Code Online (Sandbox Code Playgroud)
虽然,我发现这个 javascript 注入在 Jupyter 实验室中不起作用(Jupyter 未找到)。我的问题是如何在 Jupyter 实验室中执行与上述代码等效的操作。在检查 jupyter 实验室的 HTML 后,我找不到 Jupyter 对象。