[IPython-dev] widget value persistence
Doug Blank
doug.blank at gmail.com
Thu Feb 27 16:23:12 EST 2014
On Thu, Feb 27, 2014 at 4:11 PM, Darren Dale <dsdale24 at gmail.com> wrote:
> Do you have an example of this? I tried in one of the widget example
> notebooks and couldn't figure out how to change the default value.
>
You can just the value of the property [1], such as:
mywidget.value = 25.0
and the widget will be set to that value.
Hope that helps!
-Doug
[1] -
http://nbviewer.ipython.org/github/ipython/ipython/blob/7eac82e16e9c0c9f8e232816560963a7a07d79d1/examples/widgets/Part%201%20-%20Basics.ipynb
>
> On Thu, Feb 27, 2014 at 3:45 PM, Brian Granger <ellisonbg at gmail.com>wrote:
>
>> Yes, for now the right answer is to set the value attribute of the
>> slider when you construct it. If you are using interact, you can
>> change the default value for the widget by changing the keyword
>> argument in the function def.
>>
>> On Thu, Feb 27, 2014 at 11:57 AM, Thomas Kluyver <takowl at gmail.com>
>> wrote:
>> > Hi Darren,
>> >
>> > On 27 February 2014 11:37, Darren Dale <dsdale24 at gmail.com> wrote:
>> >>
>> >> However, I have a question about portions of the analysis that would
>> >> require user interaction via a widget. Suppose I start from an ipynb
>> >> template which includes a slider that defaults to 25. My particular
>> dataset
>> >> requires the slider to be set to 30. Is it possible for an ipynb
>> widget to
>> >> save its most recent value as the new default value for the next time
>> the
>> >> notebook is run? This would be a game-changer for developing user
>> interfaces
>> >> for scientific applications.
>> >
>> >
>> > We haven't yet worked out how to save widgets, so they disappear
>> entirely
>> > when you reload a notebook. We'll get to that for 3.0, and I imagine
>> then
>> > that the latest value of a slider will be saved with the notebook.
>> >
>> > 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 important that
>> running
>> > code has a predictable result. But I don't think this is a problem: if
>> you
>> > want the default to be 30, just set it to 30 in your code.
>> >
>> > Best wishes,
>> > Thomas
>> >
>> > _______________________________________________
>> > IPython-dev mailing list
>> > IPython-dev at scipy.org
>> > http://mail.scipy.org/mailman/listinfo/ipython-dev
>> >
>>
>>
>>
>> --
>> Brian E. Granger
>> Cal Poly State University, San Luis Obispo
>> bgranger at calpoly.edu and ellisonbg at gmail.com
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>
>
> _______________________________________________
> 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/20140227/c690d8a0/attachment.html>
More information about the IPython-dev
mailing list