Skip to content

Commit

Permalink
Merge pull request #69 from FoamyGuy/root_group_prop
Browse files Browse the repository at this point in the history
change badgerbase.show to root_group
  • Loading branch information
tannewt authored Mar 25, 2024
2 parents 9a6b39c + af60fed commit 5550334
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions adafruit_pybadger/pybadger_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion examples/pybadger_pygamer_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5550334

Please sign in to comment.