diff --git a/src/scwidgets/check/_widget_check_registry.py b/src/scwidgets/check/_widget_check_registry.py index e0c4b0b..bfdda95 100644 --- a/src/scwidgets/check/_widget_check_registry.py +++ b/src/scwidgets/check/_widget_check_registry.py @@ -147,11 +147,19 @@ def __init__(self, *args, **kwargs): self._check_all_widgets_button = Button(description="Check all widgets") self._output = Output() kwargs["layout"] = kwargs.pop("layout", Layout(width="100%")) + + self._buttons_hbox = HBox() + + # needs to be after the _buttons_hbox already was created + self.display_set_all_references_button = kwargs.pop( + "display_set_all_references_button", False + ) + VBox.__init__( self, [ CssStyle(), - HBox([self._set_all_references_button, self._check_all_widgets_button]), + self._buttons_hbox, self._output, ], *args, @@ -170,6 +178,22 @@ def checks(self): """ return self._checks + @property + def display_set_all_references_button(self) -> bool: + return self._display_set_all_references_button + + @display_set_all_references_button.setter + def display_set_all_references_button(self, value: bool): + if value: + self._display_set_all_references_button = True + self._buttons_hbox.children = ( + self._check_all_widgets_button, + self._set_all_references_button, + ) + else: + self._display_set_all_references_button = False + self._buttons_hbox.children = (self._check_all_widgets_button,) + @property def registered_widgets(self): return self._widgets.copy() diff --git a/tests/notebooks/widget_check_registry.py b/tests/notebooks/widget_check_registry.py index c2412b3..0f44dcd 100644 --- a/tests/notebooks/widget_check_registry.py +++ b/tests/notebooks/widget_check_registry.py @@ -27,7 +27,7 @@ def create_check_registry(use_fingerprint, failing, buggy): - check_registry = CheckRegistry() + check_registry = CheckRegistry(display_set_all_references_button=True) check = single_param_check( use_fingerprint=use_fingerprint, failing=failing, buggy=buggy diff --git a/tests/test_widgets.py b/tests/test_widgets.py index a019f33..9e918b4 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -979,10 +979,10 @@ def test_button_clicks( """ buttons = nb_cell.find_elements(By.CLASS_NAME, BUTTON_CLASS_NAME) - set_all_references_button = buttons[0] - assert set_all_references_button.get_property("title") == "Set all references" - check_all_widgets_button = buttons[1] + check_all_widgets_button = buttons[0] assert check_all_widgets_button.get_property("title") == "Check all widgets" + set_all_references_button = buttons[1] + assert set_all_references_button.get_property("title") == "Set all references" WebDriverWait(driver, 5).until( expected_conditions.element_to_be_clickable(check_all_widgets_button)