From af60fede3d48b72fc5465b3d72e673dafac9162b Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sun, 24 Mar 2024 20:51:05 -0500 Subject: [PATCH] change badgerbase.show to root_group --- adafruit_pybadger/pybadger_base.py | 20 +++++++++++++------- examples/pybadger_pygamer_asyncio.py | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/adafruit_pybadger/pybadger_base.py b/adafruit_pybadger/pybadger_base.py index 9c55081..8242bc8 100644 --- a/adafruit_pybadger/pybadger_base.py +++ b/adafruit_pybadger/pybadger_base.py @@ -165,7 +165,7 @@ def _create_badge_background(self) -> None: if self._background_group is None: self._background_group = displayio.Group() - self.show(self._background_group) + self.root_group = self._background_group if self._background_image_filename: file_handle = open( # pylint: disable=consider-using-with @@ -359,7 +359,7 @@ def show_custom_badge(self) -> None: if not self._created_background: self._create_badge_background() - self.show(self._background_group) + self.root_group = self._background_group # pylint: disable=too-many-arguments def _create_label_group( @@ -561,7 +561,7 @@ def show_business_card( business_card_splash.append(face_image) for group in business_card_label_groups: business_card_splash.append(group) - self.show(business_card_splash) + self.root_group = business_card_splash # pylint: disable=too-many-locals def show_badge( @@ -646,9 +646,15 @@ def show_badge( group.append(hello_group) group.append(my_name_is_group) group.append(name_group) - self.show(group) + self.root_group = group - def show(self, group) -> None: + @property + def root_group(self): + """The currently showing Group""" + return self.display.root_group + + @root_group.setter + def root_group(self, group): """Show the given group, refreshing the screen immediately""" self.activity() self.display.auto_refresh = False @@ -658,7 +664,7 @@ def show(self, group) -> None: def show_terminal(self) -> None: """Revert to terminalio screen.""" - self.show(None) + self.root_group = displayio.CIRCUITPYTHON_TERMINAL @staticmethod def bitmap_qr(matrix: adafruit_miniqr.QRBitMatrix) -> displayio.Bitmap: @@ -710,7 +716,7 @@ def show_qr_code(self, data: str = "https://circuitpython.org") -> None: ) qr_code = displayio.Group(scale=qr_code_scale) qr_code.append(qr_img) - self.show(qr_code) + self.root_group = qr_code @staticmethod def _sine_sample(length: int) -> Generator[int, None, None]: diff --git a/examples/pybadger_pygamer_asyncio.py b/examples/pybadger_pygamer_asyncio.py index 6f44731..d264101 100644 --- a/examples/pybadger_pygamer_asyncio.py +++ b/examples/pybadger_pygamer_asyncio.py @@ -50,7 +50,7 @@ async def ui_task(): email_string_two=pronoun, ) elif pybadger.button.b: - pybadger.show(qr_gp) + pybadger.root_group = qr_gp elif pybadger.button.start: pybadger.show_custom_badge() elif pybadger.button.select: