[IPython-dev] how ipython notebook support widget or applet besides HTML and code?

Matthias BUSSONNIER bussonniermatthias at gmail.com
Sat Nov 24 06:10:05 EST 2012


Le 24 nov. 2012 à 04:04, W Gong a écrit :
Hi, 

> Hi,
> I learned ipython notebook a few days ago and like it very much, 
> To me, IPython Notebook is a new generation of web browser because it brings exploration and interactivity to user.
> 
> One question is how to add widget support (e.g. embed canvas, drawing board, java applet). 

Depending on what you exactly want to do you might have different way of doing it.

The first thing you can do is use display protocol (see docs/example/notebook/display_protocol.ipynb) to define html/latex/json representation for object.

other example
http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/master/docs/examples/notebooks/00_notebook_tour.ipynb
Near the end, you have a youtube video python object which representation is an embedded youtube player.

> To illustrate my use-case, here is a notebook  that I created to teach python to 10 yr old kids. To make it more interesting or engaging, I combine rich text, image,  video with code. In this example, I used HTML() to embed a javascript clock at the beginning. But how would one do the same in python?

The other thing we are working on are json plugin
https://github.com/ipython/ipython/pull/2518

have a look at http://vimeo.com/channels/pydata/53051817
for demo.

> 
> I have another use-case to embed java applet:
> Nobel Physicist - Carl Wieman at U of Colorado - Bolder has a wonderful science education initiative called PhET which is to bring virtual lab to science students.
> If teachers and students can perform virtual experiment, at the same time, do calculations in math/physics via sympy and write a lab report, all within the IPython notebook, it would be a huge boost to our education.

You should be able to do the same and use a custom _repr_html_ to display this form python.

I think the introduction notebook in /docs/example/notebooks/ are a good start to see what could be done. 


also, you can share static version of your notebook through nbviewer.ipython.org.

here is what it looks for yours.
http://nbviewer.ipython.org/url/dl.dropbox.com/u/54552252/what-is-time.ipynb

-- 
Matthias


More information about the IPython-dev mailing list