71

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.
Thomas K
  • 37,597
  • 7
  • 80
  • 84
Nyxynyx
  • 56,949
  • 141
  • 437
  • 770
  • 4
    You may be able to edit the config file... In the meantime, if you click on the side of the result bar, it will rotate from `autoscroll` to `expanded` to `hidden`. – Reblochon Masque Apr 21 '16 at 00:15

6 Answers6

89

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

ayorgo
  • 2,523
  • 1
  • 24
  • 31
78

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.

mtd
  • 2,074
  • 17
  • 20
  • This doesn't work for me, when I run this, I get the same error as OP. – frmsaul May 25 '17 at 23:48
  • @frmsaul what version of IPython notebook are you using? Still works for me in jupyter notebook 5.x (and 4.x). – mtd Jun 15 '17 at 01:33
6

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 !!!

Nouman Ahsan
  • 259
  • 4
  • 8
4

This works for me (with no semicolon)

    %%javascript
    IPython.OutputArea.auto_scroll_threshold = 9999
3

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

%%javascript
require("notebook/js/notebook").Notebook.prototype.scroll_to_bottom = function () {}
Oldrich Svec
  • 4,161
  • 2
  • 27
  • 52
2

In the similar way that you can hack a cell to autorun, 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.

Community
  • 1
  • 1
mkst
  • 544
  • 6
  • 14