禁用 iPython Notebook 自动滚动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36757301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:17:29  来源:igfitidea点击:

Disable iPython Notebook Autoscrolling

pythonpython-2.7ipythonjupyter-notebook

提问by Nyxynyx

In iPython Notebook, is it possible to disable the autoscrolling of long outputs? Or at least set a threshold for the output length before autoscrolling sets in?

在 iPython Notebook 中,是否可以禁用长输出的自动滚动?或者至少在自动滚动设置之前为输出长度设置一个阈值?

Tried the following command

尝试了以下命令

%%javascript
IPython.OutputArea.auto_scroll_threshold = 9999;

but it gives an error

但它给出了一个错误

Javascript error adding output!
SyntaxError: Unexpected identifier
See your browser Javascript console for more details.

回答by mtd

To disable auto-scrolling, execute this javascript in a notebook cell before other cells are executed:

要禁用自动滚动,请在执行其他单元格之前在笔记本单元格中执行此 javascript:

%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
    return false;
}

There is also an ipython notebook extension, disable_autoscroll, you can use for a more permanent change. Follow ipython issue #2172for the latest details.

还有一个 ipython 笔记本扩展,disable_autoscroll,您可以用于更永久的更改。关注ipython issue #2172了解最新详情。

回答by ayorgo

Can also be done via user interface.

也可以通过用户界面完成。

  • Individual cells: Cell->Current Outputs->Toggle Scrolling
  • All cells: Cell->All Outputs->Toggle Scrolling
  • 单个单元格:单元格->当前输出->切换滚动
  • 所有单元格:单元格->所有输出->切换滚动

enter image description here

在此处输入图片说明

回答by Hugo Richard

This works for me (with no semicolon)

这对我有用(没有分号)

    %%javascript
    IPython.OutputArea.auto_scroll_threshold = 9999

回答by Oldrich Svec

To disable scroll to bottom after run allcommand, execute this code:

要在run all命令后禁用滚动到底部,请执行以下代码:

%%javascript
require("notebook/js/notebook").Notebook.prototype.scroll_to_bottom = function () {}

回答by streetster

In the similar way that you can hack a cell to autorun, you can add the following cell:

以类似的方式,您可以将单元格修改为 autorun,您可以添加以下单元格:

%%javascript
require(
        ["notebook/js/outputarea"],
        function (oa) {
            oa.OutputArea.auto_scroll_threshold = -1;
            console.log("Setting auto_scroll_threshold to -1");
        });

which will set the auto_scroll_thresholdto -1which means never autoscroll.

这将设置auto_scroll_threshold-1这意味着从不自动滚动。

This works on my notebooks that are trusted (e.g. jupyter trust notebook.ipynb), not sure if anycells are executed in untrusted notebooks.

这适用于我受信任的笔记本(例如jupyter trust notebook.ipynb),不确定是否在不受信任的笔记本中执行了任何单元格。