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

output widget append_display_data does not display widgets #1811

Open
jasongrout opened this Issue Nov 9, 2017 · 9 comments

Comments

Projects
None yet
2 participants
@jasongrout
Member

jasongrout commented Nov 9, 2017

It seems there are some problems either with the output widget append_display_data method (from #1752), or how we display widgets.

from ipywidgets import Output, IntSlider
out = Output(layout={'border': '1px solid black'})
out.append_display_data(IntSlider())
out

should capture the intslider inside of the output widget, but instead we get

screen shot 2017-11-08 at 8 56 40 pm

If I use the output widget as a context manager, it works fine:

from ipywidgets import Output, IntSlider
from IPython.display import display
out = Output(layout={'border': '1px solid black'})
with out:
    display(IntSlider())
out

screen shot 2017-11-08 at 8 58 43 pm

@jasongrout jasongrout added this to the 7.0.x milestone Nov 9, 2017

@jasongrout

This comment has been minimized.

Member

jasongrout commented Nov 9, 2017

From the docs http://ipython.readthedocs.io/en/stable/api/generated/IPython.core.formatters.html:

Prior to IPython 6.1, _ipython_display_ was the only way to display custom mime-types without registering a new Formatter.
IPython 6.1 introduces _repr_mimebundle_ for displaying custom mime-types, so _ipython_display_ should only be used for objects that require unusual display patterns, such as multiple display calls.

We use _ipython_display_, in which we manually call display to display a widget. When we switch to using _repr_mimebundle, I think this issue will resolve itself.

@jasongrout

This comment has been minimized.

Member

jasongrout commented Nov 9, 2017

IPython 6.1 was released 31 May 2017. I think it will be a while before we can mandate IPython 6.1+ (likely not until ipywidgets 8), so we may just have to live with this for now.

@jasongrout jasongrout modified the milestones: 7.0.x, Future Nov 9, 2017

@jasongrout

This comment has been minimized.

Member

jasongrout commented Nov 9, 2017

actually, we may be able to register a display using the for_type mechanism instead, until we can move to a simple _repr_mimebundle_: http://ipython.readthedocs.io/en/stable/api/generated/IPython.core.formatters.html#IPython.core.formatters.BaseFormatter.for_type

@GaiYu0

This comment has been minimized.

GaiYu0 commented Nov 26, 2017

Hi, I am experiencing a similar problem. In my case, the slider widget is displayed properly but the output widget cannot be displayed. Is there any temporary solution?

Thank you very much!

@jasongrout

This comment has been minimized.

Member

jasongrout commented Nov 27, 2017

@GaiYu0, can you post the code you are using?

@GaiYu0

This comment has been minimized.

GaiYu0 commented Nov 27, 2017

It turns out that my problem was caused by broken dependencies, which is irrelevant from this issue. Sorry!

@jasongrout

This comment has been minimized.

Member

jasongrout commented Mar 19, 2018

actually, we may be able to register a display using the for_type mechanism instead, until we can move to a simple repr_mimebundle: http://ipython.readthedocs.io/en/stable/api/generated/IPython.core.formatters.html#IPython.core.formatters.BaseFormatter.for_type

This won't work. It looks like registering a for_type handler in the ipython display formatter is equivalent to defining the _ipython_display_ function, so it doesn't get us anything more than we had.

So I'm moving this issue into the Major Release milestone, for when we can require ipython >=6.1 and define a _repr_mimebundle_ method.

@jasongrout jasongrout modified the milestones: 7.2, Major release Mar 19, 2018

@jasongrout

This comment has been minimized.

Member

jasongrout commented Mar 19, 2018

It looks like IPython 6.1 was released May 31, 2017, so we should probably wait until at least June 2018 to make this change.

@jasongrout jasongrout referenced this issue Mar 26, 2018

Merged

Centralize output widget docs #2020

5 of 5 tasks complete
@jasongrout

This comment has been minimized.

Member

jasongrout commented Mar 26, 2018

Perhaps we can put in a check for the ipython version, and use the _repr_mimebundle_ if we are in a version that supports it, and otherwise use (monkeypatch?) our class to have the _ipython_display_ method?

@jasongrout jasongrout modified the milestones: Major release, 7.2 Mar 26, 2018

jasongrout added a commit to jasongrout/ipywidgets that referenced this issue Mar 27, 2018

jasongrout added a commit to jasongrout/ipywidgets that referenced this issue Mar 27, 2018

@jasongrout jasongrout referenced a pull request that will close this issue Mar 27, 2018

Open

Use _repr_mimebundle_ in IPython 6.1 or later. #2021

jasongrout added a commit to jasongrout/ipywidgets that referenced this issue Mar 28, 2018

@jasongrout jasongrout modified the milestones: 7.2, Major release Mar 28, 2018

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