question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

htmlmanager does not seem to work with 3rd party widgets

See original GitHub issue

The output for this html is fine:

import ipywidgets as widgets
import ipywidgets.embed
slider = widgets.FloatSlider()
slider
widgets.embed.embed_minimal_html('slider.html', slider)

However, using other libraries such as ipyvolume or pythreejs does not seem to work.

from pythreejs import *
import numpy as np
from IPython.display import display
from ipywidgets import HTML, Text
from traitlets import link, dlink
ball = Mesh(geometry=SphereGeometry(radius=1), 
                                    material=LambertMaterial(color='red'),
                                    position=[2, 1, 0])

scene = Scene(children=[ball, AmbientLight(color='#777777')])

c = PerspectiveCamera(position=[0, 5, 5], up=[0, 0, 1],
                      children=[DirectionalLight(color='white', 
                                                 position=[3, 5, 1], 
                                                 intensity=0.5)])
renderer = Renderer(camera=c, 
                    scene=scene, 
                    controls=[OrbitControls(controlling=c)])
display(renderer)

Chrome’s screenshot for network gives this:

screen shot 2017-07-29 at 19 23 17

When I put jupyter-threejs.js in the same folder, it gives this: screen shot 2017-07-29 at 19 24 35

I tried to debug it, but I’m not sure what’s going on here. Not that in the last case, it even tried to fetch file:///Users/maartenbreddels/src/ipywidgets/@jupyter-widgets/base.js (pythreejs master and ipywidgets master)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jasongroutcommented, Aug 1, 2017

The root issue seems to be fixed in #1556 - now the three packages @jupyter-widgets/base, @jupyter-widgets/controls, and @jupyter-widgets/html-manager are all defined in require on a page that just includes the embed.js script.

1reaction
pbugnioncommented, Jul 30, 2017

Good catch. I don’t think that threejs has been migrated to ipywidgets 7.0.0. As far as I can tell, the migration would involve:

  • setting the _model_module_version traitlet explicitly – at the moment it defaults to the version on the base widget (hence why it tries to look for jupyter-threejs@0.3.0 on unpkg).
  • changing references from jupyter-js-widgets to @jupyter-widgets/base.

We should probably write a migration guide for widget libraries and make an effort to help widget library developers with the migration?

That said, looking at ipyleaflet 0.4.0-alpha1, which has been migrated, the htmlmanager still doesn’t work. As far as I can tell, this is because we’ve split the htmlmanager from the base package. Before, we could just rely on declaring that jupyter-js-widgets is available as an external dependency when building external widgets. Now (looking at webpack.config.js for ipyleaflet and the cookiecutter), we declare that @jupyter-widgets/base should be provided as an external dependency, but we don’t provide it explicitly.

I can see two possible fixes:

  • remove the externals field for the embeddable bundle for ipyleaflet (see this PR on ipyleaflet). The base widget classes then get bundled with ipyleaflet. This definitely works, but might be confusing to the user: there are then two versions of @jupyter-widgets/base in the DOM: the one provided by the html-manager and the one provided by ipyleaflet.

  • explicitly pass in the base widgets to the requirejs configuration (presumably in /packages/html-manager/src/embed-webpack.ts?). This could also be confusing for the end-user because they developed against one version of @jupyter-widgets/base, but when their code is embedded, they actually get a different one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jquery Widget CSS conflicts with third-party site - Stack Overflow
I have created one Jquery widgets which is used in many third party website. My Widgets has it's own css for widgets elements....
Read more >
iPhone SE 2020 widgets doesn't support 3rd party apps
Does iPhone SE 2020 widgets support 3rd party apps? I can't seem to do it. I only see widgets from the original list....
Read more >
@vscode/jupyter-ipywidgets - NPM Package Overview - Socket
umd is does not work as we have multiple entry points in webpack . Heres' the solution define('@jupyter-widgets/controls', () => widgets);.
Read more >
Migrating custom widget libraries — Jupyter Widgets 8.0.2 ...
These are migration guides specifically for developers of third-party widgets. Migrating from 7.x to 8.0 . In this section, we discuss migrating...
Read more >
Best Practices on Embedding Third-Party Web Widgets
Therefore, let's look at several best practices to reduce their overall impact. 1. Lazy-Loading. We can use Lazy loading to load embedded ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found