From 48e1a0b2bc88093ad7b315ca2defb87b7c3f4168 Mon Sep 17 00:00:00 2001 From: Gordon Ball Date: Mon, 22 Sep 2014 21:23:51 +0200 Subject: [PATCH] s/choose/manual/g --- IPython/html/widgets/__init__.py | 2 +- IPython/html/widgets/interaction.py | 28 +++++++++---------- .../html/widgets/tests/test_interaction.py | 8 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/IPython/html/widgets/__init__.py b/IPython/html/widgets/__init__.py index e14c77392..2e9352254 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 fe7080c8d..f8f8d3e0f 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 7d9ef7e89..79d35e568 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)