Skip to content

Conversation

@jasongrout
Copy link
Member

Otherwise sometimes the display message will be processed before the update message.

Otherwise sometimes the display message will be processed before the update message.
@jasongrout
Copy link
Member Author

@jdfreder, @SylvainCorlay - review?

@SylvainCorlay
Copy link
Member

I confirm that it solves my issue. This looks good.

@jasongrout
Copy link
Member Author

@jdfreder, @minrk - I think this bug fix could be a candidate for 3.0. The problem Sylvain was seeing was that if you created a widget in the same cell as displaying it, where the widget is dynamically loaded using requirejs, it often would not show up since the display message would beat the update message.

@minrk
Copy link
Member

minrk commented Feb 17, 2015

Can you show an example that fails?

@minrk minrk added this to the 3.0 milestone Feb 17, 2015
@SylvainCorlay
Copy link
Member

You only need to use a custom model that is asynchronously loaded. For example, if you do

In /nbextensions/Foo/Bar.js

define(["widgets/js/widget"], function(Widget) {
    "use strict";
    var Bar= Widget.WidgetModel;
    return {
        Bar: Bar,
    };
});

Then we simple declare a Slider that uses this model:

from IPython.html.widgets import IntSlider
from IPython.utils.traitlets import Unicode
from IPython.display import display

class BarSlider(IntSlider):
    _model_name = Unicode('Bar', sync=True)
    _model_module = Unicode('nbextensions/Foo/Bar', sync=True)

slider = BarSlider()
display(slider)

In manager.js, the call to load_class Line 181 requires the view name and module path, which are part of the model state.

@jasongrout jasongrout mentioned this pull request Feb 17, 2015
@jdfreder
Copy link
Contributor

I haven't seen this problem myself with my ipython-flightwidgets repo. Is it frequent? @SylvainCorlay 's example code should work as-is.

@SylvainCorlay
Copy link
Member

It is because you don't overload the model in your flight widget. This only
happens with overloaded models.
On Feb 19, 2015 12:12 PM, "Jonathan Frederic" notifications@github.com
wrote:

I haven't seen this problem myself with my ipython-flightwidgets repo. Is
it frequent? @SylvainCorlay https://github.com/SylvainCorlay 's example
code should work as-is.


Reply to this email directly or view it on GitHub
#7801 (comment).

@jdfreder
Copy link
Contributor

Oh I see, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state_change is probable a bad name for the promise since we use it more generically, but we can change it later.

jdfreder added a commit that referenced this pull request Feb 19, 2015
Force display_message to be processed in order
@jdfreder jdfreder merged commit 92333e1 into ipython:master Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants