[IPython-dev] Default values for widgets

Brian Granger ellisonbg@gmail....
Sat Feb 8 16:56:40 CST 2014


This function:

https://github.com/ipython/ipython/blob/master/IPython/html/widgets/interaction.py#L121

has two branches where it tests for:

elif default is not empty:

Just remove those.  Then you would need to add logic *after* the
actual widgets that does something like:

widget.value = default

To set the value to the default. The only difficulty is for something
like a slider widget with finite step sizes, we would have to think
about what to do if the value wasn't at a valid step:

(0, 100, 10) with a default of 33

We could just allow it , or we could raise a ValueError.

On Sat, Feb 8, 2014 at 2:47 PM, Stéfan van der Walt <stefan@sun.ac.za> wrote:
> On Sat, 08 Feb 2014 14:20:32 -0800, Brian Granger wrote:
>> Right now, we look at the following places for widget abbreviations:
>>
>> 1. kwargs to interact
>> 2. annotations
>> 3. defaults to individual keyword args in the def of the function.
>
> I can certainly add a PR to set the default widget value from the keyword.
> Another question: how do you prevent a keyword argument from being turned into
> a widget?  Currently all arguments are processed, irrespective of whether they
> are specified in "interactive".
>
> Stéfan
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com


More information about the IPython-dev mailing list