From 2ecdf22f84e003cdebc521ee016fdb3e04e2578f Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 7 Mar 2022 15:34:41 -0800 Subject: [PATCH 1/3] Added function to remove all text --- adafruit_portalbase/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/adafruit_portalbase/__init__.py b/adafruit_portalbase/__init__.py index 510784d..4868a15 100755 --- a/adafruit_portalbase/__init__.py +++ b/adafruit_portalbase/__init__.py @@ -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, @@ -213,6 +213,15 @@ def add_text( # pylint: enable=too-many-arguments + def remove_all_text(self, clear_font_cache=False): + """Remove all added text. + + :param bool clear_font_cache: Clear the font cache. Defaults to False. + """ + self._text = [] + if clear_font_cache: + self._fonts = {} + def set_text(self, val, index=0): """Display text, with indexing into our list of text boxes. From f463e6fb4259ca1835d5ea3b625ff2e69f576d74 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 7 Mar 2022 15:51:41 -0800 Subject: [PATCH 2/3] Remove labels as well --- adafruit_portalbase/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/adafruit_portalbase/__init__.py b/adafruit_portalbase/__init__.py index 4868a15..f21093d 100755 --- a/adafruit_portalbase/__init__.py +++ b/adafruit_portalbase/__init__.py @@ -214,10 +214,15 @@ def add_text( # pylint: enable=too-many-arguments def remove_all_text(self, clear_font_cache=False): - """Remove all added text. + """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 = {} From 41a895c373f43661ddbcfd1c379d8832e5656650 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 7 Mar 2022 15:53:31 -0800 Subject: [PATCH 3/3] Add a Garbage Collect after removing stuff --- adafruit_portalbase/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_portalbase/__init__.py b/adafruit_portalbase/__init__.py index f21093d..6db809b 100755 --- a/adafruit_portalbase/__init__.py +++ b/adafruit_portalbase/__init__.py @@ -226,6 +226,7 @@ def remove_all_text(self, clear_font_cache=False): 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.