Fra*_*urt 7 python jupyter-notebook
在我选择run all、run all above或run all belowJupyter 笔记本后,如何跳转到当前正在运行的单元格?
谢谢你的这个想法,亚伦。但它在完整运行时只能工作一次,因此需要改进以使其更有用。
我把它扩展成一个快捷方式,在notebook执行过程中可以多次使用。
将此添加到~/.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;
}
});
Run Code Online (Sandbox Code Playgroud)
现在,您可以随时按下Alt-I,让笔记本将视图重新聚焦到正在运行的单元格上。
接下来最好编写一个扩展/快捷方式,在所有执行过程中保持当前正在运行的单元格的视图处于焦点。
虽然不是特别优雅,但当我需要这样的自定义功能时,我会使用 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);
});
Run Code Online (Sandbox Code Playgroud)