Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display by default not the set_all_references_button in the CheckRegistry #44

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/scwidgets/check/_widget_check_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/notebooks/widget_check_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading