Disable iPython Notebook Autoscrolling

PythonPython 2.7IpythonJupyter Notebook

Python Problem Overview


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?

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.

Python Solutions


Solution 1 - Python

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

Solution 2 - Python

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

%%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 #2172 for the latest details.

Solution 3 - Python

To prevent scrolling within a single cell output, select the cell and press Shift+O while in command state. It will toggle output for that particular cell. If you want all the cells to display long outputs without scrolling, then go to the Cell tab -> All Outputs -> Toggle Scrolling. That's it !!!

Solution 4 - Python

This works for me (with no semicolon)

    %%javascript
    IPython.OutputArea.auto_scroll_threshold = 9999

Solution 5 - Python

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

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

Solution 6 - Python

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

%%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_threshold to -1 which means never autoscroll.

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

[1]: https://stackoverflow.com/a/38856870/7290888 "hack cells to autorun"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNyxynyxView Question on Stackoverflow
Solution 1 - PythonayorgoView Answer on Stackoverflow
Solution 2 - PythonmtdView Answer on Stackoverflow
Solution 3 - PythonNouman AhsanView Answer on Stackoverflow
Solution 4 - PythonHugo RichardView Answer on Stackoverflow
Solution 5 - PythonOldrich SvecView Answer on Stackoverflow
Solution 6 - PythonmkstView Answer on Stackoverflow