From 876158e94e902b75ab094808285fd01467f17242 2014-09-22 19:23:51 From: Gordon Ball Date: 2014-09-22 19:23:51 Subject: [PATCH] s/choose/manual/g --- diff --git a/IPython/html/widgets/__init__.py b/IPython/html/widgets/__init__.py index e14c773..2e93522 100644 --- a/IPython/html/widgets/__init__.py +++ b/IPython/html/widgets/__init__.py @@ -9,7 +9,7 @@ from .widget_int import IntText, BoundedIntText, IntSlider, IntProgress, IntRang from .widget_selection import RadioButtons, ToggleButtons, Dropdown, Select from .widget_selectioncontainer import Tab, Accordion from .widget_string import HTML, Latex, Text, Textarea -from .interaction import interact, interactive, fixed, interact_choose +from .interaction import interact, interactive, fixed, interact_manual # Deprecated classes from .widget_bool import CheckboxWidget, ToggleButtonWidget diff --git a/IPython/html/widgets/interaction.py b/IPython/html/widgets/interaction.py index fe7080c..f8f8d3e 100644 --- a/IPython/html/widgets/interaction.py +++ b/IPython/html/widgets/interaction.py @@ -175,7 +175,7 @@ def interactive(__interact_f, **kwargs): """Build a group of widgets to interact with a function.""" f = __interact_f co = kwargs.pop('clear_output', True) - choose = kwargs.pop('__choose', False) + manual = kwargs.pop('__manual', False) kwargs_widgets = [] container = Box() container.result = None @@ -197,9 +197,9 @@ def interactive(__interact_f, **kwargs): c = [w for w in kwargs_widgets if isinstance(w, DOMWidget)] # If we are only to run the function on demand, add a button to request this - if choose: - choose_button = Button(description="Run %s" % f.__name__) - c.append(choose_button) + if manual: + manual_button = Button(description="Run %s" % f.__name__) + c.append(manual_button) container.children = c # Build the callback @@ -210,8 +210,8 @@ def interactive(__interact_f, **kwargs): container.kwargs[widget.description] = value if co: clear_output(wait=True) - if choose: - choose_button.disabled = True + if manual: + manual_button.disabled = True try: container.result = f(**container.kwargs) except Exception as e: @@ -221,15 +221,15 @@ def interactive(__interact_f, **kwargs): else: ip.showtraceback() finally: - if choose: - choose_button.disabled = False + if manual: + manual_button.disabled = False # Wire up the widgets - # If we are doing choose running, the callback is only triggered by the button + # If we are doing manual running, the callback is only triggered by the button # Otherwise, it is triggered for every trait change received # On-demand running also suppresses running the fucntion with the initial parameters - if choose: - choose_button.on_click(call_f) + if manual: + manual_button.on_click(call_f) else: for widget in kwargs_widgets: widget.on_trait_change(call_f, 'value') @@ -266,15 +266,15 @@ def interact(__interact_f=None, **kwargs): return f return dec -def interact_choose(__interact_f=None, **kwargs): - """interact_choose(f, **kwargs) +def interact_manual(__interact_f=None, **kwargs): + """interact_manual(f, **kwargs) As `interact()`, generates widgets for each argument, but rather than running the function after each widget change, adds a "Run" button and waits for it to be clicked. Useful if the function is long-running and has several parameters to change. """ - return interact(__interact_f, __choose=True, **kwargs) + return interact(__interact_f, __manual=True, **kwargs) class fixed(HasTraits): """A pseudo-widget whose value is fixed and never synced to the client.""" diff --git a/IPython/html/widgets/tests/test_interaction.py b/IPython/html/widgets/tests/test_interaction.py index 7d9ef7e..79d35e5 100644 --- a/IPython/html/widgets/tests/test_interaction.py +++ b/IPython/html/widgets/tests/test_interaction.py @@ -481,16 +481,16 @@ def test_custom_description(): description='foo', ) -def test_interact_choose_button(): - c = interactive(f, __choose=True) +def test_interact_manual_button(): + c = interactive(f, __manual=True) w = c.children[0] check_widget(w, cls=widgets.Button) -def test_interact_choose_nocall(): +def test_interact_manual_nocall(): callcount = 0 def calltest(testarg): callcount += 1 - c = interactive(calltest, testarg=5, __choose=True) + c = interactive(calltest, testarg=5, __manual=True) c.children[0].value = 10 nt.assert_equal(callcount, 0)