[IPython-dev] Wrap Javascript (D3.js) file into IPython Widget

Wes Turner wes.turner at gmail.com
Tue Oct 14 03:39:03 EDT 2014


You should be able to implement an object with a _repr_html_ method
that generates the HTML you'd like to include into the page.

e.g.: https://github.com/Psycojoker/ipython-beautifulsoup/blob/master/soup.py#L93

If your CSS clashes with the IPython notebook CSS, an IFrame may be
the better option. (see:
https://github.com/Psycojoker/ipython-beautifulsoup/issues/2 for an
explanation of the security implications)

IPython documentation:

* http://ipython.org/ipython-doc/dev/config/integrating.html#rich-display
* http://nbviewer.ipython.org/github/ipython/ipython/blob/1.x/examples/notebooks/Part%205%20-%20Rich%20Display%20System.ipynb

On Sat, Oct 11, 2014 at 8:23 AM, Lucien Boillod <lucienboillod at gmail.com> wrote:
> Hi all,
>
> I currently work with d3.js ans I almost finished (fidd here:
> http://jsfiddle.net/mv9L7hjq/15/), but now I have to include this part into
> the project (https://www.lrde.epita.fr/wiki/Vaucanson), so basically we use
> IPython notebook for the graphical user interface, and what we would like to
> do is simply wrap my work on D3 into a IPython widget, so that we can
> display it when we need it.
> I have made some research about IPython widget using Javascript but all I
> found is something like that
> (http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Interactive%20Widgets/Custom%20Widget%20-%20Hello%20World.ipynb)
> But clearly I don’t want to rewrite the whole javascript file, but just load
> it and wrap both (HTML/CSS/JS) into a widget. I wonder if there is a way to
> do that ?
>
> Thank you,
>
> Cheers,
>
> LB
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>



-- 
Wes Turner
https://westurner.github.io/



More information about the IPython-dev mailing list