Back-End implementation of IPython Widget

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Back-End implementation of IPython Widget

Lucien Boillod
Hello all,

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.

Thank you,

Cheers,

Lucien Boillod
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Back-End implementation of IPython Widget

rossant
> 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.

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

Cyrille
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Back-End implementation of IPython Widget

Lucien Boillod

> Le 18 nov. 2014 à 17:29, Cyrille Rossant <[hidden email]> 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
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Back-End implementation of IPython Widget

Thomas Kluyver-2
On 19 November 2014 01:53, Lucien Boillod <[hidden email]> wrote:
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))

I think you're asking about how to get the JS part of the widget onto the page. Have a look at what I do with the turtle widget in mobilechelonian - when you instantiate it, it copies the JS into nbextensions, and the widget specifies _view_module to tell the frontend where to load its JS component from.

https://github.com/takluyver/mobilechelonian

Thomas

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev