[IPython-dev] Implementing widgets

Jacob Vanderplas jakevdp at cs.washington.edu
Sat Jun 8 17:43:56 EDT 2013


Very cool!
One comment: I think that rather than passing python_var an explicit name,
it might be better to populate a dict in the IPython namespace with the
names of objects that need to be accessed by the javascript.  i.e., within
the slider init function, you could have something along the lines of:

```
import IPython
if not hasattr(IPython, "_interactive_elements"):
    IPython._interactive_elements = {}

key = random.randint(0, 1E7)  # or use some sort of hash function
IPython._interactive_elements[key] = self
self._python_var = "IPython._interactive_elements[%i]" % key
```

That would keep track of the object names in the background.
Other than that, I like the implementation!
   Jake


On Sat, Jun 8, 2013 at 12:25 PM, Ondřej Čertík <ondrej.certik at gmail.com>wrote:

> Hi,
>
> I have implemented the slider widget here:
>
> http://nbviewer.ipython.org/5736280
>
> >From the cell [2] you can see how it is used, it's trivial. I suggest
> you run this in your local notebook, because the cell output is not
> visible in the nbviewer. Also you need Chrome, as Firefox doesn't
> support the HTML 5 slider and I haven't figure out how to use jquery's
> slider yet.
>
> I read your roadmap, and my understanding is that the plan is to start
> developing this in December. Unfortunately I needed something now, so
> I wrote the above.
>
> I have already tested it for rotation of a 3D visualization using VTK
> 6 in ipython notebook (offscreen rendering) and it works great.
>
> What is your plan and actual ideas how these widgets should be implemented?
> Is there a reason why work on this cannot start now? I'll be happy to
> help with this
> and send PRs.
>
> If I recall correctly, you wanted to implement the widgets using the
> IPython implementation of traits?
>
> Ondrej
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130608/160c2d07/attachment.html>


More information about the IPython-dev mailing list