Not working with anywidget: Class null not found in module @jupyter-widgets/base@2.0.0 #89
Closed
Description
anywidget is a new way of developing ipywidgets with a claim for being easier and more modern. For example mapwidget is built on top of anywidget.
I reported in #88 that mapwidget.cesium is not working with ipywidgets-bokeh and Panel. So I thought I would try out a basic anywidget example. And I can see that it raises the same issue.
Reproducible Example
pip install panel==0.14.4 ipywidgets-bokeh==1.3.0 anywidget==0.2.0
script.py
import anywidget
import traitlets
import panel as pn
pn.extension("ipywidgets")
class CounterWidget(anywidget.AnyWidget):
_esm = """
export function render(view) {
let getCount = () => view.model.get("count");
let button = document.createElement("button");
button.classList.add("counter-button");
button.innerHTML = `count is ${getCount()}`;
button.addEventListener("click", () => {
view.model.set("count", getCount() + 1);
view.model.save_changes();
});
view.model.on("change:count", () => {
button.innerHTML = `count is ${getCount()}`;
});
view.el.appendChild(button);
}
"""
_css="""
.counter-button { background-color: #ea580c; }
.counter-button:hover { background-color: #9a3412; }
"""
count = traitlets.Int(0).tag(sync=True)
counter = CounterWidget()
pn.panel(counter).servable()
panel serve script.py
Open http://localhost:5006/script and see the exception in the browser console.
Class null not found in module @jupyter-widgets/base@2.0.0
Metadata
Assignees
Labels
No labels
Activity