Skip to content

change badgerbase.show to root_group #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading