From f2f23bb1f467302448e79e10f418e77d5a7f8418 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Fri, 25 Apr 2025 09:15:21 -0500 Subject: [PATCH] bugfix: don't set class attr to dynamic method --- src/seedsigner/gui/components.py | 15 +++++++++++---- src/seedsigner/gui/screens/screen.py | 9 +++++++++ tests/screenshot_generator/generator.py | 7 ++++++- tests/test_flows_l10n.py | 1 - 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/seedsigner/gui/components.py b/src/seedsigner/gui/components.py index a7e7bb46..eee30773 100644 --- a/src/seedsigner/gui/components.py +++ b/src/seedsigner/gui/components.py @@ -1360,8 +1360,12 @@ class Button(BaseComponent): text_y_offset: int = 0 background_color: str = GUIConstants.BUTTON_BACKGROUND_COLOR selected_color: str = GUIConstants.ACCENT_COLOR + + # Cannot define these class attrs w/the get_*_font_*() methods because the attrs will + # not be dynamically reinterpreted after initial class import. font_name: str = None font_size: int = None + font_color: str = GUIConstants.BUTTON_FONT_COLOR selected_font_color: str = GUIConstants.BUTTON_SELECTED_FONT_COLOR outline_color: str = None @@ -1674,8 +1678,12 @@ class TopNav(BaseComponent): background_color: str = GUIConstants.BACKGROUND_COLOR icon_name: str = None icon_color: str = GUIConstants.BODY_FONT_COLOR - font_name: str = GUIConstants.get_top_nav_title_font_name() - font_size: int = GUIConstants.get_top_nav_title_font_size() + + # Cannot define these class attrs w/the get_*_font_*() methods because the attrs will + # not be dynamically reinterpreted after initial class import. + font_name: str = None + font_size: int = None + font_color: str = GUIConstants.BODY_FONT_COLOR show_back_button: bool = True show_power_button: bool = False @@ -1688,8 +1696,7 @@ class TopNav(BaseComponent): if not self.font_size: self.font_size = GUIConstants.get_top_nav_title_font_size() - print(f"self.font_size: {self.font_size}") - + super().__post_init__() if not self.width: self.width = self.canvas_width diff --git a/src/seedsigner/gui/screens/screen.py b/src/seedsigner/gui/screens/screen.py index 0a623ce7..03f7d180 100644 --- a/src/seedsigner/gui/screens/screen.py +++ b/src/seedsigner/gui/screens/screen.py @@ -289,8 +289,12 @@ class ButtonListScreen(BaseTopNavScreen): selected_button: int = 0 is_button_text_centered: bool = True is_bottom_list: bool = False + + # Cannot define these class attrs w/the get_*_font_*() methods because the attrs will + # not be dynamically reinterpreted after initial class import. button_font_name: str = None button_font_size: int = None + button_selected_color: str = GUIConstants.ACCENT_COLOR # Params for version of list used for Settings @@ -554,8 +558,12 @@ class ButtonListScreen(BaseTopNavScreen): @dataclass class LargeButtonScreen(BaseTopNavScreen): button_data: list = None + + # Cannot define these class attrs w/the get_*_font_*() methods because the attrs will + # not be dynamically reinterpreted after initial class import. button_font_name: str = None button_font_size: int = None + button_selected_color: str = GUIConstants.ACCENT_COLOR selected_button: int = 0 @@ -563,6 +571,7 @@ class LargeButtonScreen(BaseTopNavScreen): if not self.button_font_name: self.button_font_name = GUIConstants.get_button_font_name() if not self.button_font_size: + # TODO: Define the +2 with a constant or via a formula (e.g. int(x * 1.1)) self.button_font_size = GUIConstants.get_button_font_size() + 2 super().__post_init__() diff --git a/tests/screenshot_generator/generator.py b/tests/screenshot_generator/generator.py index be7dc0d2..b81df21b 100644 --- a/tests/screenshot_generator/generator.py +++ b/tests/screenshot_generator/generator.py @@ -183,7 +183,12 @@ def generate_screenshots(locale): if settings_entry.visibility == SettingsConstants.VISIBILITY__HIDDEN: continue - settings_views_list.append(ScreenshotConfig(settings_views.SettingsEntryUpdateSelectionView, dict(attr_name=settings_entry.attr_name), screenshot_name=f"SettingsEntryUpdateSelectionView_{settings_entry.attr_name}")) + if settings_entry.attr_name == SettingsConstants.SETTING__LOCALE: + # Locale selection has its own dedicated View + settings_views_list.append(ScreenshotConfig(settings_views.LocaleSelectionView)) + else: + # Generic SettingsEntry selection View + settings_views_list.append(ScreenshotConfig(settings_views.SettingsEntryUpdateSelectionView, dict(attr_name=settings_entry.attr_name), screenshot_name=f"SettingsEntryUpdateSelectionView_{settings_entry.attr_name}")) settingsqr_data_persistent = f"settings::v1 name=English_noob_mode persistent=E coords=spa,spd denom=thr network=M qr_density=M xpub_export=E sigs=ss scripts=nat xpub_details=E passphrase=E camera=0 compact_seedqr=E bip85=D priv_warn=E dire_warn=E partners=E locale={locale}" settingsqr_data_not_persistent = f"settings::v1 name=Mode_Ephemeral persistent=D coords=spa,spd denom=thr network=M qr_density=M xpub_export=E sigs=ss scripts=nat xpub_details=E passphrase=E camera=0 compact_seedqr=E bip85=D priv_warn=E dire_warn=E partners=E locale={locale}" diff --git a/tests/test_flows_l10n.py b/tests/test_flows_l10n.py index 71ce1fb6..1814f995 100644 --- a/tests/test_flows_l10n.py +++ b/tests/test_flows_l10n.py @@ -13,7 +13,6 @@ from seedsigner.views.view import MainMenuView class TestL10nFlows(FlowTest): def test_change_locale(self): settings_entry = SettingsDefinition.get_settings_entry(SettingsConstants.SETTING__LOCALE) - spanish_display_name = SettingsConstants.ALL_LOCALES[SettingsConstants.LOCALE__SPANISH] # Initially we get English assert _(MainMenuView.SCAN.button_label) == "Scan"