Skip to content

Added function to remove all text #62

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 3 commits into from
Mar 8, 2022
Merged
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
17 changes: 16 additions & 1 deletion adafruit_portalbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PortalBase:

"""

# pylint: disable=too-many-instance-attributes, too-many-branches
# pylint: disable=too-many-instance-attributes, too-many-branches, too-many-public-methods
def __init__(
self,
network,
Expand Down Expand Up @@ -213,6 +213,21 @@ def add_text(

# pylint: enable=too-many-arguments

def remove_all_text(self, clear_font_cache=False):
"""Remove all added text and labels.

:param bool clear_font_cache: Clear the font cache. Defaults to False.
"""

# Remove the labels
for i in range(len(self._text)):
self.set_text("", i)
# Remove the data
self._text = []
if clear_font_cache:
self._fonts = {}
gc.collect()

def set_text(self, val, index=0):
"""Display text, with indexing into our list of text boxes.

Expand Down