[IPython-dev] embedding js9 into a notebook

Nicholas Bollweg nick.bollweg at gmail.com
Fri Oct 2 10:24:18 EDT 2015

Started a draft earlier, lost it.

js9 looks very cool! I'd love to see it integrated!

I would recommend doing an nbextension and wrapping your view in a widget,
packaged up as a python module. Then you either have to tell the user to
install the files to the magic location, or do it for them (as qgrid, with
its nbinstall) based on something they do.

Though they are not the same thing, the big advantage to nbextensions and
widgets are:

   - widgets: interactive integration with all the other widget things:
   layouts, controls, etc.
   - Some Day being able to use your front end work with another kernel

When integrating with the notebook front end from python "simply", a higher
order pattern than publish_display_data is:

*def show(data):   display.display(Javascript("..**.data..."))*

Every time you want to change something, you call show. If you want to have
the frontend do something to the backend, you do something like


Eventually, you will end up reimplementing most of what widgets do.

With widgets,

*class SomeWidget(Widget):   _view_module = Unicode

*)   _view_name = Unicode ("SomeView")   Data = SomeTrait()*

*x = SomeWidget() display.display(x) x.data = data*

You can work with the widget instance as a normal python object... But it
has a secret life up in the browser, and you don't have to worry about
state, which is huge. Now your view/backend is part of the larger widget
ecosystem, and other widgets can be linked to it without any additional
integration work, and you're really pushing
All that being said, this is not as easy as it could be. The issue arises
from "the notebook" as the user perceives it, actually being:

   - the kernel: do compute
   - the server: provision compute, serve static assets
   - their code and data

The single user, native kernel, local install experience has suffered
somewhat from the needs of the distributed, multi-user, multi-kernel
experience. In the case of javascript, the kernel doesn't even know it's
running a notebook (could be running shell or qt... or whatever).

So we're stuck right now with:

   - install your backend package into the kernel
   - install the extension into the server

Here is an exhaustive issue describing some of the issues (with pictures!):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20151002/a94d5c8d/attachment.html>

More information about the IPython-dev mailing list