[IPython-dev] Back-End implementation of IPython Widget

Lucien Boillod lucienboillod at gmail.com
Wed Nov 19 04:53:18 EST 2014


> Le 18 nov. 2014 à 17:29, Cyrille Rossant <cyrille.rossant at gmail.com> a écrit :
> 
>> I would like to know more about your back-end implementation of your widget, specially using Javascript.
>> Indeed when one of your widget is used into the notebook, the Javascript source code doesn't appear into ipynb source.
>> But in my implementation I use display(Javascript(myjavascript)) in my back-end file (.py) and consequences are unconvenients because
>> each times my .py file is import or executed, the javascript appear directly in the ipynb source.
> 
> That might be because built-in widgets use a dedicated widget
> architecture, whereas you use the rich display feature which is
> different as far as I can tell.
> 

I use the same functionality and structure than built-in widgets, but I don’t do it directly in the notebook but in my separate file .py, 
and I call my widget with a magic command ( because of the Bi-directionnality between my project and the widget ).

> If you want to use the same functionality than built-in widgets,
> you'll have to build custom widgets as described here:
> http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Interactive%20Widgets/Custom%20Widget%20-%20Hello%20World.ipynb
> 
> This tutorial might also be of interest:
> https://github.com/rossant/euroscipy2014
> 


But my question was really on the execution of the javascript part, as far as I can see in both of your examples the same method as me is used,
because %%javascript is just a alias for the rich display feature display(Javascript(js))

And I wonder what is you back-end implementation in ipython notebook ( not in widget that people can create ).
What I would like is have a new type of widget that I load into my notebook, but I don’t don’t load the javascript in the notebook, so %%javascript can’t work, that’s why I use display(Javascript(js)) and that’s work very well but I just wonder if I can get around the fact my Javascript code appear on the notebook metadata when we explore the .ipynb file where we have load the widget.

Maybe it’s not odd and it’s because of the implementation of .ipynb file, I just was surprised to find the whole Javascript in the metadata.

Thank you,

Lucien


More information about the IPython-dev mailing list