sos-notebook icon indicating copy to clipboard operation
sos-notebook copied to clipboard

Displaying only the last "screen"

Open BoPeng opened this issue 8 years ago • 5 comments
trafficstars

Not at all sure if it can be done but one problem with the notebook interface is that the outputs are appended to the output cell and you have to constantly scroll to check the last few lines. Perhaps we can do something like auto-scroll, or show only the last 50 lines of results to give users a familiar "terminal" feeling.

BoPeng avatar Oct 26 '17 13:10 BoPeng

There is an extension .. https://www.quora.com/Is-there-a-way-to-configure-Jupyter-notebook-to-auto-scroll-output-cells

BoPeng avatar Oct 26 '17 14:10 BoPeng

The key code seems to be something like


        $(".output").on("resize", function () {
            if (!params.scrollDownIsEnabled) return;
            var output = $(this);
            setTimeout(function () {
                output.scrollTop(output.prop("scrollHeight"));
                console.log("height: " + output.prop("scrollHeight"));
            }, 0);
        });

BoPeng avatar Oct 26 '17 14:10 BoPeng

The code was for Jupyter 4.x and I have adapted it for Jupyter 5.x.

BoPeng avatar Oct 28 '17 04:10 BoPeng

Somehow does not work now.

BoPeng avatar Nov 13 '17 06:11 BoPeng

Not sure why but scrolling sometimes work and sometimes not.

import time
for i in range(50):
   sh('ls')
   sh(f'echo {i}')
   time.sleep(0.3)

BoPeng avatar Feb 02 '18 22:02 BoPeng