euroscipy2014
euroscipy2014 copied to clipboard
porting to newer version of jupyter
Hi,
I'm trying to port those very helpful notebooks to run under latest version of the jupyter-notebook. I was able to successfully convert the [01_interact , 02_gui , 04_dataviz] notebooks, but I'm having some difficulties with the 03_custom notebook.
The changes I made are available as gist.
The problem I'm having with 03_custom notebook.
Reading from version3_widget_migration I changed the js code from:
%%javascript
// We import the WidgetManager.
require(["widgets/js/widget"], function(WidgetManager){
// We define the NumberSelector view here.
var NumberSelector = widget.DOMWidgetView.extend({
// Function for rendering the view.
render: function(){
to:
%%javascript
// We import the WidgetManager.
require(["widget"], function(WidgetManager){
// We define the NumberSelector view here.
var NumberSelector = widget.DOMWidgetView.extend({
// Function for rendering the view.
render: function(){
using require(["widget”] … instead of require(["widgets/js/widget … and widget.DOMWidgetView.extend instead of IPython.DOMWidgetView.extend
but when testing the widget at the code cell 4 i have (log from the js console):
Couldn't create a view for model id '8727d6f51f804c7aa582b3d95b3c630d' -- Error: Class NumberSelector not found in registry (…)
I guess the last line in the js code:
WidgetManager.register_widget_view('NumberSelector', NumberSelector);
didn’t worked.
Have you any idea on how to fix this? thanks!
Unfortunately it's been a while since I used this API... I invite you to ask the ipywidget devs, for example @jdfreder @sylvaincorlay @jasongrout
@sylvaincorlay recently spent some time with the require paths.
Off the top of my head
require(["widgets/js/widget"], function(WidgetManager){
would change to
require(["nbextensions/widgets/js/manager", "nbextensions/widgets/js/widget"], function(manager, widget){
and
WidgetManager.register_widget_view
to
manager.WidgetManager.register_widget_view
For more information about the syntax, read about AMD, require.js, and Javascript.
@jdfreder thx. In general, I would not recommend using register_widget_view for custom widgets.
In general, I would not recommend using register_widget_view for custom widgets.
ditto