[IPython-dev] Updating saved cell content with widgets

Phil Elson pelson.pub at gmail.com
Wed Apr 16 03:00:29 EDT 2014


I've been playing with the slider widget and have defined a callback along
the lines of:


from IPython.html import widgets
slider = widgets.IntSliderWidget(min=-20, max=20, value=10)

def on_value_change(name, value):
    from IPython.core.display import clear_output
    clear_output(wait=True)
    print 'Current value:', value
slider.on_trait_change(on_value_change, 'value')


The problem with this though is that when I save the notebook, neither the
slider nor the printed value are stored in the notebook file on save. Is
there a way to update the content of the stored cell either from within the
callback, or via an alternative hook?

The answer might be identical, but I'm also working on my own widget which
I would like to save a static representation of inside the notebook file
(as HTML). Is there an "on-save" hook I can attach a callback to to convert
my dynamic widget into a static on at save time?

Cheers!

Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140416/af99e131/attachment.html>


More information about the IPython-dev mailing list