From 273cd528218b7ea3b583a3fa276f76e9419b7d01 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 11 Jun 2025 13:26:56 -0700 Subject: [PATCH 1/2] Change splash to root_group --- adafruit_portalbase/__init__.py | 39 +++++++++++++++++++++------------ adafruit_portalbase/graphics.py | 22 ++++++++++++++----- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/adafruit_portalbase/__init__.py b/adafruit_portalbase/__init__.py index 0326550..86b9571 100644 --- a/adafruit_portalbase/__init__.py +++ b/adafruit_portalbase/__init__.py @@ -73,12 +73,8 @@ def __init__( # noqa: PLR0912,PLR0913 Too many branches,Too many arguments in f self.network = network """The :py:class:`~adafruit_portalbase.NetworkBase`-derived instance provided""" self.graphics = graphics - """The :py:class:`~adafruit_portalbase.GraphicsBase`-derived instance provided""" - self.splash = self.graphics.splash - """The :py:meth:`displayio.Group()` object that acts as the splash screen + """The :py:meth:`displayio.Group()` object that acts as the root group screen for this device.""" - self.display = self.graphics.display - """The :py:class:`busdisplay.BusDisplay` object representing the screen for this device""" # Font Cache self._fonts = {} @@ -267,7 +263,7 @@ def set_text(self, val, index=0): # noqa: PLR0912 Too many branches string = string[: self._text[index]["maxlen"] - 3] + "..." else: string = string[: self._text[index]["maxlen"]] - index_in_splash = None + index_in_root_group = None if len(string) > 0 and self._text[index]["wrap"]: if self._debug: @@ -278,7 +274,7 @@ def set_text(self, val, index=0): # noqa: PLR0912 Too many branches if self._text[index]["label"] is not None: if self._debug: print("Replacing text area with :", string) - index_in_splash = self.splash.index(self._text[index]["label"]) + index_in_root_group = self.root_group.index(self._text[index]["label"]) elif self._debug: print("Creating text area with :", string) if len(string) > 0: @@ -288,22 +284,22 @@ def set_text(self, val, index=0): # noqa: PLR0912 Too many branches text=string, scale=self._text[index]["scale"], ) - if index_in_splash is not None: - self.splash[index_in_splash] = self._text[index]["label"] + if index_in_root_group is not None: + self.root_group[index_in_root_group] = self._text[index]["label"] else: - self.splash.append(self._text[index]["label"]) + self.root_group.append(self._text[index]["label"]) else: self._text[index]["label"].text = string self._text[index]["label"].color = self._text[index]["color"] self._text[index]["label"].anchor_point = self._text[index]["anchor_point"] self._text[index]["label"].anchored_position = self._text[index]["position"] self._text[index]["label"].line_spacing = self._text[index]["line_spacing"] - elif index_in_splash is not None: + elif index_in_root_group is not None: self._text[index]["label"] = None - # Remove the label from splash - if index_in_splash is not None and self._text[index]["label"] is None: - del self.splash[index_in_splash] + # Remove the label from root group + if index_in_root_group is not None and self._text[index]["label"] is None: + del self.root_group[index_in_root_group] gc.collect() def preload_font(self, glyphs=None, index=0): @@ -552,3 +548,18 @@ def json_path(self, value): self._json_path = (value,) else: self._json_path = None + + @property + def root_group(self): + """The root display group for this device.""" + return self.graphics.root_group + + @property + def splash(self): + """The root display group for this device (for backwards compatibility).""" + return self.graphics.root_group + + @property + def display(self): + """The displayio.Display object for this device.""" + return self.graphics.display diff --git a/adafruit_portalbase/graphics.py b/adafruit_portalbase/graphics.py index 711c7cc..0f699ae 100644 --- a/adafruit_portalbase/graphics.py +++ b/adafruit_portalbase/graphics.py @@ -47,16 +47,16 @@ def __init__(self, display, *, default_bg=0x000000, scale=1, debug=False): # no if self._debug: print("Init display") - self.splash = displayio.Group(scale=scale) + self._root_group = displayio.Group(scale=scale) self._qr_group = None if self._debug: print("Init background") self._bg_group = displayio.Group() - self.splash.append(self._bg_group) + self._root_group.append(self._bg_group) # set the default background if default_bg is not None: - self.display.root_group = self.splash + self.display.root_group = self._root_group self.set_background(default_bg) gc.collect() @@ -110,8 +110,8 @@ def qrcode(self, qr_data, *, qr_size=1, x=0, y=0, qr_color=0x000000): # noqa: P """ if qr_data is None: - if self._qr_group and self._qr_group in self.splash: - self.splash.remove(self._qr_group) + if self._qr_group and self._qr_group in self._root_group: + self._root_group.remove(self._qr_group) self._qr_group = None gc.collect() return @@ -154,8 +154,18 @@ def qrcode(self, qr_data, *, qr_size=1, x=0, y=0, qr_color=0x000000): # noqa: P pass else: self._qr_group = displayio.Group() - self.splash.append(self._qr_group) + self._root_group.append(self._qr_group) self._qr_group.scale = qr_size self._qr_group.x = x self._qr_group.y = y self._qr_group.append(qr_sprite) + + @property + def root_group(self): + """The display's root group.""" + return self._root_group + + @property + def splash(self): + """The display's root group (for backwards compatibility).""" + return self.display._root_group From 6c4c3a9f6dcd3b840592b7f4c658e010b1fc2a88 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 11 Jun 2025 13:28:08 -0700 Subject: [PATCH 2/2] Add warnings --- adafruit_portalbase/__init__.py | 4 ++++ adafruit_portalbase/graphics.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/adafruit_portalbase/__init__.py b/adafruit_portalbase/__init__.py index 86b9571..31196a0 100644 --- a/adafruit_portalbase/__init__.py +++ b/adafruit_portalbase/__init__.py @@ -557,6 +557,10 @@ def root_group(self): @property def splash(self): """The root display group for this device (for backwards compatibility).""" + print( + "WARNING: splash is deprecated, use root_group instead. " + "This will be removed in a future release." + ) return self.graphics.root_group @property diff --git a/adafruit_portalbase/graphics.py b/adafruit_portalbase/graphics.py index 0f699ae..b1a92a3 100644 --- a/adafruit_portalbase/graphics.py +++ b/adafruit_portalbase/graphics.py @@ -168,4 +168,8 @@ def root_group(self): @property def splash(self): """The display's root group (for backwards compatibility).""" + print( + "WARNING: splash is deprecated, use root_group instead. " + "This will be removed in a future release." + ) return self.display._root_group pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy