[IPython-dev] widget value persistence
Matthias BUSSONNIER
bussonniermatthias at gmail.com
Fri May 23 04:21:06 EDT 2014
Le 22 mai 2014 à 17:31, Vasco Tenner a écrit :
> Dear all,
> On 02/27/2014 10:10 PM, Darren Dale wrote:
>> However, if you re-run the cell, I think it will (and should) always
>> return the default to what the code specifies. I think it's
> What I quite often do to preserve the settings of a widget:
>
> 1. Create a widget
> w = interactive(function)
> display(w)
>
> 2. The just print the values of the sliders:
> w.kwargs
>
> 3. Then copy this output in a new cell.
> good_kwargs = {'a':1}
>
> What would help me is if I can set the values of the widgets with
> something like:
> w = interactive(function)
> w.kwargs = good_kwargs
> display(w)
>
> Is there a way to achieve this?
from IPython.html.widgets import interactive
def fun(c=0, a=1):
return a+c
w = interactive(fun,**{'c':12,'a':7})
display(w)
Does what you expect it to do.
--
M
>
> Kind regards,
> Vasco
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
More information about the IPython-dev
mailing list