Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable scrolling of Output widget #1791

Open
oschuett opened this issue Nov 2, 2017 · 14 comments
Open

Disable scrolling of Output widget #1791

oschuett opened this issue Nov 2, 2017 · 14 comments

Comments

@oschuett
Copy link

oschuett commented Nov 2, 2017

I'm using the Output widget to display lengthy content. At some point the auto-scrolling of the output-area kicks in. It would be great if there were a simple way to disable scrolling e.g. Output(scroll=False)

@jasongrout
Copy link
Member

Definitely! This should be pretty straightforward to do.

@jasongrout jasongrout added this to the 7.0.x milestone Nov 2, 2017
@jasongrout
Copy link
Member

I think I would prefer a view-level control, like in the notebook (clicking on the prompt area toggles the scroll state). That may be (a) easier to implement and (b) more natural and consistent with current notebook outputs. Right now, we hide the prompt area in that output area because it's rather annoying when nesting output widgets. However, if we can come up with a good UI (perhaps a very narrow area to the right of the output widget?), I think that would be better than programmatic control.

@oschuett
Copy link
Author

oschuett commented Nov 2, 2017

I would really like to also have some programmatic control. The big difference wrt. top-level output areas is that their initial scroll state is stored in the ipynb file. Hence, I would suggest sth. like Output(initial_scroll_state=...).

@eayoungs
Copy link

eayoungs commented Dec 1, 2017

Hey, there; I'm an aspiring contributor and I'd like to take a shot at tackling this issue.

Cheers

Eric

@beasteers
Copy link

Any headway on this issue?

@IssamLaradji
Copy link

is there a fix to this? the output widget still gets the scroll bar when its content gets large.

@dieterwang
Copy link

If you're trying to display html in your Output, you could wrap the content into a <div style="none"> so that the scollbar isn't triggered. Then, after a short delay (100ms was enough for me), show it again. Something like below

html = """
    <div id="foo" style="display:none;">
    ## actual content ##
    </div>
"""
display_html(html, raw=True)
display_javascript("setTimeout(function(){$('#foo').show()}, 100)", raw=True)

@evanreichard
Copy link

I'm using this to disable all auto scroll bars on the whole page. Im sure you could combine this with some JS to find nearest element so it would only apply to a single output.

style = """
    <style>
        .output_scroll {
            height: unset !important;
            border-radius: unset !important;
            -webkit-box-shadow: unset !important;
            box-shadow: unset !important;
        }
    </style>
    """
display(HTML(style))

@sitnarf
Copy link

sitnarf commented Jan 25, 2020

I edited @evanreichard snippet to disable scrolling only for all output widgets:

style = """
    <style>
       .jupyter-widgets-output-area .output_scroll {
            height: unset !important;
            border-radius: unset !important;
            -webkit-box-shadow: unset !important;
            box-shadow: unset !important;
        }
        .jupyter-widgets-output-area  {
            height: auto !important;
        }
    </style>
    """
display(HTML(style))

@gsteele13
Copy link

And what if it is not an HTML ouput?

I'm trying to display a long output with print() and am getting a scroll bar that I would like to avoid....

thanks!

@xuancong84
Copy link

I edited @evanreichard snippet to disable scrolling only for all output widgets:

style = """
    <style>
       .jupyter-widgets-output-area .output_scroll {
            height: unset !important;
            border-radius: unset !important;
            -webkit-box-shadow: unset !important;
            box-shadow: unset !important;
        }
        .jupyter-widgets-output-area  {
            height: auto !important;
        }
    </style>
    """
display(HTML(style))

Your solution works perfect. I think your code should be in the default Jupyter Notebook initialization code base because user can still toggle the output widget scroll behaviour by clicking the left region to the output widget. The existing Jupyter notebook code toggles between a slightly longer scroll and slightly shorter scroll, that is meaningless.

@robelgeda
Copy link

Thank you all for looking at this, it saved me a lot of trouble
@gsteele13 You just copy and paste this before you initate your widget and it should work:

import ipywidgets as widgets
from IPython.display import display

style = """
    <style>
       .jupyter-widgets-output-area .output_scroll {
            height: unset !important;
            border-radius: unset !important;
            -webkit-box-shadow: unset !important;
            box-shadow: unset !important;
        }
        .jupyter-widgets-output-area  {
            height: auto !important;
        }
    </style>
    """
display(widgets.HTML(style))
wd = widgets.interact(slider, x=widgets.BoundedIntText(min=0, max=len(result_cat)-1))

@keriheuer
Copy link

Is there a way to disable horizontal scrolling of any output from widgets? This code works great for preventing a vertical scrollbar from appearing but I also don't want any horizontal scrollbar showing up. My widgets outputs are not nearly as wide as the entire screen (I am using Google Colab by the way) and yet a scrollbar always appears...

I have set widget widths via Layout(), specified overflow="visible" via style(), and even tried adding a width="auto !important" to the above code snippet but no luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests