Skip to content

code to reproduce output from "Widgets -> Embed Widgets" #1654

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

Closed
hainm opened this issue Aug 18, 2017 · 12 comments
Closed

code to reproduce output from "Widgets -> Embed Widgets" #1654

hainm opened this issue Aug 18, 2017 · 12 comments
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@hainm
Copy link

hainm commented Aug 18, 2017

hi,

I am working embedding nglview. The "Widgets -> Embed Widgets" works nicely (I can see the render after open the html file).

However, using the python API won't give the same expectation.

embed.embed_minimal_html('index2.html', [view], requirejs=True)

I guess I miss something here. Can you help? thanks

screen shot 2017-08-17 at 8 52 45 pm

@hainm
Copy link
Author

hainm commented Aug 18, 2017

Please see attach files for working (with "Widgets -> Embed Widgets") and non_working html
(from API)

working.txt

non_working.txt

@jasongrout
Copy link
Member

jasongrout commented Aug 18, 2017

The non-working example is missing some key properties in the widget state, namely the _view_* properties.

@hainm
Copy link
Author

hainm commented Aug 18, 2017

Is that intentional?

@hainm
Copy link
Author

hainm commented Aug 18, 2017

uhm, I actually get the same error if trying sphinx-jupyter PR from jupyter/jupyter-sphinx#16

screen shot 2017-08-17 at 9 18 49 pm

@hainm
Copy link
Author

hainm commented Aug 18, 2017

By the way, ipywidgets 7 is awesome and I love it much. ;)

@jasongrout
Copy link
Member

jasongrout commented Aug 18, 2017

It is intentional (default is to get the data without default values). I'm considering whether it is the best, though. Usually these _view_* properties are set as defaults in javascript. Do your javascript models have the appropriate _view_* defaults defined?

@jasongrout
Copy link
Member

jasongrout commented Aug 18, 2017

The defaults are only defined on the model, not the view. The defaults defined at https://github.com/arose/nglview/blob/master/js/src/widget_ngl.js#L27 should be moved up to the model at https://github.com/arose/nglview/blob/master/js/src/widget_ngl.js#L17

(That also explains why the javascript embedding worked - it also deleted any default values, but since you didn't define defaults for the view information, that was saved in the document.)

@jasongrout jasongrout added this to the Reference milestone Aug 18, 2017
@jasongrout
Copy link
Member

By the way, ipywidgets 7 is awesome and I love it much. ;)

Thanks! And thanks for testing things out!

@hainm
Copy link
Author

hainm commented Aug 18, 2017

Do your javascript models have the appropriate view* defaults defined?

I am not sure what you meant here (due to my lack of understanding about how ipywidgets works).

But below is a short chunk of codes:
https://github.com/arose/nglview/blob/84a5873d98a703e1057b845026faae6aa4130f60/js/src/widget_ngl.js#L16-L36

@hainm
Copy link
Author

hainm commented Aug 18, 2017

It is intentional (default is to get the data without default values).

so, are you going to change it? If not yet, what's the idiom to make nglview work with sphinx-jupyter? thanks.

@jasongrout
Copy link
Member

@hainm
Copy link
Author

hainm commented Aug 18, 2017

wow, work like a charm. Thanks Jason. (see the attached wow.txt (-> wow.html) and the figure).

wow.txt

screen shot 2017-08-18 at 12 55 57 am

cc @arose

Happy to close this issue.

@jasongrout PS: May be updating docs if there is not yet. :)

@hainm hainm closed this as completed Aug 18, 2017
@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

2 participants