-
Notifications
You must be signed in to change notification settings - Fork 11
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
Adding bokeh view information to ipywidget model #58
Comments
To add some context, this issue affects custom widgets which don't render fully until after being mounted. For example, an export class ExampleView extends DOMWidgetView {
render() {
this.el.classList.add('custom-widget');
setTimeout(() => {
this.el.innerHTML = '<div style="width: 500px; height: 500px; background-color: red"></div>'
}, 5000)
return;
}
} will render a big red square in a Jupyter notebook, but will not show anything in an app served by import panel as pn
from ipywidgets_bokeh import IPyWidget
from myproject import ExampleWidget
pn.extension('ipywidgets')
def app():
return pn.Column(
IPyWidget(widget=ExampleWidget())
)
pn.serve({'app': app}, port=8890) I spent some time making the |
@peytondmurray As we discussed, here are the steps to reproduce the issue:
So far you should be able to reproduce it in a notebook. To reproduce it with ipywidget-bokeh, here is what I did: And this should help you reproduce the issue. |
Hey @govinda18, I've been testing out strategies to handle this issue. In particular I've been trying to listen for ipywidgets events which I can use to trigger layout invalidation on the bokeh side. To do this, in the For reasons that might be clearer to someone who knows a lot more about ipywidgets internals, this callback seems to fire immediately when the widget is loaded, rather than when the widget actually renders. In short, this approach still doesn't work. On a related note, I also went back to my custom-ipywidget-example and noticed that the return value of the ipywidget EditOkay, this approach actually seems like it works, but for the life of me I cannot get firefox to clear its cache and use the new js bundle from my most recent custom-ipywidget-example. For today I'm going to pause this, and I'll get this together into a PR later on. With chromium I was able to clear the cache, use the updated js bundle from custom-ipywidgets-example, and it just worked. So in summary:
@govinda18 Does this seem like an acceptable solution to you? |
Given that bokeh (2.x) CSS layout engine needs a layout invalidation using
view.invalidate_layout
, it might be the case that an ipywidget needs to call theinvalidate_layout
method.For example, if the view creation uses react rendering (react-widget-cookiecutter), it might be the case that the rendering inside the div is done after the component is mounted causing bokeh to mess up the layout.
It will be helpful to attach the bokeh view to the DOMWidgetModel so that a custom widget can use the bokeh view methods if need be when used in a bokeh environment.
The text was updated successfully, but these errors were encountered: