在Jupyter笔记本中选择run all
,run all above
或run all below
后,如何跳转到当前正在运行的单元格?
答案 0 :(得分:4)
谢谢你的想法,亚伦。但它只能在完整运行中运行一次,因此需要进行改进才能更有用。
我已将其扩展为可在笔记本执行期间多次使用的快捷方式。
将其添加到~/.jupyter/custom/custom.js
:
// Go to Running cell shortcut
Jupyter.keyboard_manager.command_shortcuts.add_shortcut('Alt-I', {
help : 'Go to Running cell',
help_index : 'zz',
handler : function (event) {
setTimeout(function() {
// Find running cell and click the first one
if ($('.running').length > 0) {
//alert("found running cell");
$('.running')[0].scrollIntoView();
}}, 250);
return false;
}
});
现在,您可以随时按Alt-I
让笔记本将视图重新聚焦到正在运行的单元格。
接下来,编写一个扩展/快捷方式会很好,它可以在所有执行过程中保持当前正在运行的单元格的视图。
答案 1 :(得分:3)
虽然不是特别优雅,但当我需要这样的自定义功能时,我会使用jupyter的custom.js。
以下代码段绑定到按钮的单击事件并选择当前正在执行的单元格。您可以将其放在~/.jupyter/custom/custom.js
$('#run_all_cells, #run_all_cells_above, #run_all_cells_below').click(function() {
setTimeout(function() {
// Find running cell and click the first one
if ($('.running').length > 0) {
$('.running')[0].click();
}
}, 250);
});