Merge pull request #7508 from minrk/widget-description-kwarg

Don't use widget.description as kwarg key
This commit is contained in:
Thomas Kluyver 2015-01-20 09:04:02 -08:00
commit 7b8a64241f
2 changed files with 10 additions and 2 deletions

View File

@ -155,6 +155,7 @@ def _widgets_from_abbreviations(seq):
widget = _widget_from_abbrev(abbrev, default)
if not widget.description:
widget.description = name
widget._kwarg = name
result.append(widget)
return result
@ -194,7 +195,7 @@ def interactive(__interact_f, **kwargs):
container.kwargs = {}
for widget in kwargs_widgets:
value = widget.value
container.kwargs[widget.description] = value
container.kwargs[widget._kwarg] = value
if co:
clear_output(wait=True)
if manual:

View File

@ -489,13 +489,20 @@ def test_default_description():
)
def test_custom_description():
c = interactive(f, b=widgets.Text(value='text', description='foo'))
d = {}
def record_kwargs(**kwargs):
d.clear()
d.update(kwargs)
c = interactive(record_kwargs, b=widgets.Text(value='text', description='foo'))
w = c.children[0]
check_widget(w,
cls=widgets.Text,
value='text',
description='foo',
)
w.value = 'different text'
nt.assert_equal(d, {'b': 'different text'})
def test_interact_manual_button():
c = interactive(f, __manual=True)