【发布时间】:2015-09-14 21:06:32
【问题描述】:
我最近构建的 Jupyter 有一个菜单操作允许您重新启动并运行所有:
我想添加一个绑定到此操作的键盘快捷键。我已经看到documentation 用于键盘自定义,但我仍然不确定如何添加键盘快捷键。
我已经从源代码构建了 Juypter,因此根据帮助,看来我需要向 notebook/static/custom/custom.js 添加一些代码。
我尝试添加以下内容:
IPython.keyboard_manager.command_shortcuts.add_shortcut('meta-r', function (event) {
IPython.notebook.restart_kernel();
IPython.notebook.execute_run_all();
return false;
});
但是,当我按下 [Meta-r] 时,内核似乎重新启动,但 execute_run_all() 没有被执行。
【问题讨论】:
-
注意要使其自动加载,您需要将其包装为 show here