Panel meets K3D-jupyter

I had almost decided to hack the Function grapher at https://github.com/stemkoski/stemkoski.github.com
when I came across https://github.com/K3D-tools/K3D-jupyter/

One puzzle remains: The graph is added to a pn.pane.Pane.
Setting a size for the pane displays the plot, but the actual plot size
is slightly larger than the pn pane for some reason.
Any clue how to fix this would be appreciated!!

The notebook with the code is on gitlab:
https://gitlab.com/ea42gh/elementary-linear-algebra/-/blob/master/QuadricSurfaceDisplay.ipynb

3 Likes

Really Nice. Thanks for sharing. :+1:

have you tried setting the margin of the Pane to 0? Does it work?

1 Like

yes! margin=15 did the trick! Thank you @Marc

1 Like

Great you got it working @ea42gh.

How does the K3D-jupyter control compare to VTK? Could you do the same with VTK?

I have not used VTK in a very long time…
K3D-jupyter proved very simple.
From its documentation, it is supposed to play nicely with VTK.

1 Like

Hi @ea42gh.

When I add .servable() to the notebook and run it via `panel serve QuadricSurfaceDisplay.ipynb’ it looks like

and there are errors in the console.

Do you know why that is?. And how to solve it?

@Marc,
no, I have not seen that yet.
What I do see:

  • the repository code works in Chromium
  • the repository code does not work in firefox:
    it fails to load with an error
    failed to load https://unpkg.com/@holoviz/panel@^0.10.2/dist/panel.min.js
    in the console…
  • what change did you make to the notebook before serving it?
    I’d like to see if I can duplicate what you are seeing

Hi @ea42gh

The only thing I’ve done is to add .servable() like below

Then I run it with panel serve QuadricSurfaceDisplay.ipynb and get the errors.

For reference I’ve attached the modified notebook.

QuadricSurfaceDisplay.ipynb (48.2 KB)

I don’t need it working for work. But it would be nice to show case that it’s possible to serve apps using k3d. There are a lot of cool examples in their docs.

Any help is appreciated. Even just a bug report on Github :slight_smile:

Weird:
when I try to serve the notebook and open it in either Firefox or Chromium, I get

b1f0>: No module named 'ipywidgets_bokeh'
File "ipywidget.py", line 23, in _get_ipywidget:
from ipywidgets_bokeh.widget import IPyWidget Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
    exec(self._code, module.__dict__)
  File "/home/user/CODE/Langs/Julia/elementary-linear-algebra/QuadricSurfaceDisplay.ipynb", line 153, in <module>
    "  }\n",
  File "/home/user/.local/lib/python3.8/site-packages/panel/viewable.py", line 313, in servable
    self.server_doc(title=title, location=True)
  File "/home/user/.local/lib/python3.8/site-packages/panel/viewable.py", line 749, in server_doc
    model = self.get_root(doc)
  File "/home/user/.local/lib/python3.8/site-packages/panel/viewable.py", line 482, in get_root
    root = self._get_model(doc, comm=comm)
  File "/home/user/.local/lib/python3.8/site-packages/panel/layout/base.py", line 112, in _get_model
    objects = self._get_objects(model, [], doc, root, comm)
  File "/home/user/.local/lib/python3.8/site-packages/panel/layout/base.py", line 102, in _get_objects
    child = pane._get_model(doc, root, model, comm)
  File "/home/user/.local/lib/python3.8/site-packages/panel/pane/ipywidget.py", line 38, in _get_model
    model = self._get_ipywidget(self.object, doc, root, comm, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/panel/pane/ipywidget.py", line 23, in _get_ipywidget
    from ipywidgets_bokeh.widget import IPyWidget
ModuleNotFoundError: No module named 'ipywidgets_bokeh'

So I installed ipywidgets_bokeh.

Now I get:

Model 'ipywidgets_bokeh.widget.IPyWidget' does not exist. This could be due to a widget or a custom model not being registered before first usage.
1 Like

Really weird: upgraded some libraries. Current status:

  • chromium partially displays the GUI. The plot appears to be a tiny little area at the top left.
    Console shows:
ipywidgets_bokeh.js:1 TypeError: Cannot read property resizeHelper of undefined
    at r.handleResize (k3d.js:563)
  • Firefox yields an empty display with
    Uncaught ReferenceError: requirejs is not defined
1 Like