[IPython-dev] New WebGL-based protein widget + two questions

Robert McGibbon rmcgibbo at gmail.com
Mon Sep 1 21:42:58 EDT 2014


Hey guys,

This weekend I started messing around with the interactive widget system,
with the goal of adding interactive
protein structure visualization with WebGL to a library I work on (
http://mdtraj.org/). The result is pretty nice, as
you can see a short screencast <https://www.youtube.com/watch?v=Lwy2Hdsr518>.
 The code is all here
<https://github.com/rmcgibbo/mdtraj/tree/master/MDTraj/html>.

This was my first time using the widget system, and I have a couple
questions. Apologies in advance if they've been
addressed previously on the list.

1) What are the recommended best practices for deploying static javascript
assets to the browser? You can see in the
screencast that I'm calling a function `enable_notebook()` first, which
uses a combination of `IPython.display.display()`
 and `IPython.html.install_nbextension` to configure requirejs with the
paths to some libraries I need from the cdns as
well as moving our own javascript files into `.ipython/nbextensions`. This
is a little cumbersome for the users I think, and
there seem to be potentially some unfortunate race conditions if the code
that `display()`s the declaration of the browser-side
widget view class is in the same cell as the first call that actually
creates the widget on the python side.

I looked a little bit at Jake Vanderplas's mpld3, and there a lot of the
javascript libraries seem to be, by default, pulled directly
from github to avoid forcing the user to move the assets into
`.ipython/nbextensions`.

2) Is there any support in IPython for creating "static" versions of
widgets that don't require a live kernel? This protein view widget,
for example, could basically have been rewritten as just a standard
_repr_html_ with a lot of javascript (assuming all of the libraries
were server from the web instead of /nbextensions). You wouldn't have the
interactivity from the python side, but it would still be a
very rich experience. Being able to have 'static' views of the widget would
enable us to publish some really awesome example
notebooks onto the project webpage, for instance (
http://mdtraj.org/latest/examples/).

-Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140901/ba63b2bb/attachment.html>


More information about the IPython-dev mailing list