jupyter / colaboratory

[deprecated] Jupyter CoLaboratory, goto google colab now
https://colab.research.google.com
BSD 3-Clause "New" or "Revised" License
740 stars 111 forks source link

IPython javascript widgets in colaboratory? #107

Closed ceball closed 7 years ago

ceball commented 10 years ago

Hi

I have a short IPython notebook with a simple widget that runs fine under IPython notebook 2.1.0, but which I can't get to work with colaboratory. I'm running the "classic web app" on my own computer i.e. python -m colaboratory, I launch chrome with --disable-web-security, and I visit http://127.0.0.1:8844 to use colaboratory.

The notebook contains the following three cells (the .ipynb file is at https://drive.google.com/file/d/0B2GEeTv36tvTb0FCRWU3eHFqWWM/view?usp=sharing):

from __future__ import print_function
from IPython.html import widgets
from IPython.utils.traitlets import Unicode

class DateWidget(widgets.DOMWidget):
    _view_name = Unicode('DatePickerView', sync=True)
from IPython.display import Javascript
Javascript("$.getScript('test.js');")
DateWidget()

And test.js is just:

require(["widgets/js/widget"], function(WidgetManager){

    var DatePickerView = IPython.DOMWidgetView.extend({
        render: function(){ this.$el.text('Hello World!'); },
    });

    WidgetManager.register_widget_view('DatePickerView', DatePickerView);
});

This works in IPython notebook. For testing in colaboratory, I put test.js in colaboratory/resources/colab/ and I changed the second cell's Javascript() call to Javascript("$.getScript('/colab/test.js');"). When I call DateWidget() I don't see any widget, and the browser console log says:

No such target registered:  WidgetModel comm.js:80
Available targets are:  Object {} 

I'm not familiar with IPython notebook's widgets, so I'm trying to puzzle my way backwards from this error message at the moment. I'd be grateful for any pointers!

Thanks Chris

KesterTong commented 9 years ago

currently coLaboratory doesn't support widgets. This is mainly because we were basing coLaboratory off a version of IPython before widgets were introduced. We have some long term plans for re-syncing coLaboratory with IPython/Jupyter master, but until then we probably won't be adding support for widgets.

rgbkrk commented 7 years ago

This version of colaboratory is no longer supported, please switch to https://colab.research.google.com.