From f4cd7015f72a7c9b6febf2cef9d204fb140e607d Mon Sep 17 00:00:00 2001 From: Maic Siemering Date: Fri, 7 Mar 2025 21:45:28 +0100 Subject: [PATCH 1/3] fix UITextWidget subclasses did not set style during construction, causing a double render --- arcade/gui/widgets/buttons.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arcade/gui/widgets/buttons.py b/arcade/gui/widgets/buttons.py index 2c339db9a9..5a120f2300 100644 --- a/arcade/gui/widgets/buttons.py +++ b/arcade/gui/widgets/buttons.py @@ -140,6 +140,12 @@ def __init__( bind(self, "_textures", self.trigger_render) + # prepare label with default style + style = self.get_current_style() + if style is None: + raise ValueError(f"No style found for state {self.get_current_state()}") + self._apply_style(style) + def get_current_state(self) -> str: """Returns the current state of the button i.e.disabled, press, hover or normal.""" if self.disabled: @@ -330,6 +336,12 @@ def __init__( **kwargs, ) + # prepare label with default style + style = self.get_current_style() + if style is None: + raise ValueError(f"No style found for state {self.get_current_state()}") + self._apply_style(style) + def get_current_state(self) -> str: """Returns the current state of the button i.e.disabled, press, hover or normal.""" if self.disabled: From 1c7c18d71475b676c81b70637492a35b79d52d03 Mon Sep 17 00:00:00 2001 From: Maic Siemering Date: Fri, 7 Mar 2025 22:21:11 +0100 Subject: [PATCH 2/3] gui: fix update font triggered render on each frame, when font_color was not a Color --- arcade/gui/widgets/text.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arcade/gui/widgets/text.py b/arcade/gui/widgets/text.py index e79b198140..16f8e932b5 100644 --- a/arcade/gui/widgets/text.py +++ b/arcade/gui/widgets/text.py @@ -273,6 +273,9 @@ def update_font( font_bold = bold if bold is not None else self._label.bold font_italic = italic if italic is not None else self._label.italic + # ensure type of font_color, label will allways be a color + font_color = Color.from_iterable(font_color) + # Check if values actually changed, if then update and trigger render font_name_changed = self._label.font_name != font_name font_size_changed = self._label.font_size != font_size From 214ffa6a1058aaabf3676c8e0b541eb85ed62f5b Mon Sep 17 00:00:00 2001 From: Maic Siemering Date: Fri, 7 Mar 2025 22:30:56 +0100 Subject: [PATCH 3/3] fix types --- arcade/gui/widgets/buttons.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arcade/gui/widgets/buttons.py b/arcade/gui/widgets/buttons.py index 5a120f2300..c3588e4284 100644 --- a/arcade/gui/widgets/buttons.py +++ b/arcade/gui/widgets/buttons.py @@ -141,10 +141,10 @@ def __init__( bind(self, "_textures", self.trigger_render) # prepare label with default style - style = self.get_current_style() - if style is None: + _style = self.get_current_style() + if _style is None: raise ValueError(f"No style found for state {self.get_current_state()}") - self._apply_style(style) + self._apply_style(_style) def get_current_state(self) -> str: """Returns the current state of the button i.e.disabled, press, hover or normal.""" @@ -337,10 +337,10 @@ def __init__( ) # prepare label with default style - style = self.get_current_style() - if style is None: + _style = self.get_current_style() + if _style is None: raise ValueError(f"No style found for state {self.get_current_state()}") - self._apply_style(style) + self._apply_style(_style) def get_current_state(self) -> str: """Returns the current state of the button i.e.disabled, press, hover or normal."""