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

rework k3d widget for html output #53

Open
CagtayFabry opened this issue Jan 13, 2022 · 6 comments
Open

rework k3d widget for html output #53

CagtayFabry opened this issue Jan 13, 2022 · 6 comments
Labels
enhancement New feature or request K3D

Comments

@CagtayFabry
Copy link
Member

CagtayFabry commented Jan 13, 2022

The current k3d widget (for CSM, SpatialData etc.) is based on ipywidgets with python kernel interactions
Most of the interactions should be possible to archive with jslink (without needing python kernel)

This would allow the generated widget to be saved as html (and embedded later) with the ipywidgets interactions intact, see here for an example
In addition, it should be possible to display the k3d output (including controls) in sphinx documentation
https://ipywidgets.readthedocs.io/en/latest/embedding.html

This would only leave the animation part to require the python kernel (which could be implemented using the k3d animation feature at the cost of probably huuuuge resulting html files depending on the animation)

@CagtayFabry CagtayFabry added enhancement New feature or request K3D labels Jan 13, 2022
@CagtayFabry
Copy link
Member Author

k3d output works as interactive with nbsphinx after k3d=2.12

marscher added a commit to marscher/weldx-widgets that referenced this issue May 12, 2022
@marscher
Copy link
Contributor

nbconvert has an option to store the widget state, but that doesn't seem to have the effect, that the widget is also embedded. https://github.com/jupyter/nbconvert/pull/900/files#diff-bee04d71b1dfc0202a0239b1513fd81d983edc339a9734ca4f4813276feed032R175

@CagtayFabry
Copy link
Member Author

the current controls won't work because they are are not linked with jslink (and thus require a python kernel in the background that is not present on the static site)

@marscher
Copy link
Contributor

So only the time slider is currently linked (https://github.com/BAMWelDX/weldx-widgets/blob/main/weldx_widgets/visualization/csm_k3d.py#L768). So the other elements of the control group need to be linked as well.
My previous comment refers to the fact, that the k3d Plot object is not being embedded.

@marscher
Copy link
Contributor

Saving the widget state (in Jupyter lab) and manually converting via nbconvert --to html works. So the remaining tasks seem to be:

  1. use jslink for all remaining control widgets to make them independent of a kernel
  2. convince nbsphinx to preserve and include the widget state

@CagtayFabry
Copy link
Member Author

I plan to do a major restructure on the whole k3d implementation at some point, including reworking the interface and moving as many components over to jslink. Just a heads up 😉

if you want to change something in the current interface I would suggest connecting the show/hide buttons with their k3d object properties using jsdlink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request K3D
Projects
None yet
Development

No branches or pull requests

2 participants