Skip to content

Commit a9bc7d7

Browse files
authored
Merge pull request #62 from makermelissa/main
Added function to remove all text
2 parents 1a06e84 + 41a895c commit a9bc7d7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

adafruit_portalbase/__init__.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PortalBase:
5555
5656
"""
5757

58-
# pylint: disable=too-many-instance-attributes, too-many-branches
58+
# pylint: disable=too-many-instance-attributes, too-many-branches, too-many-public-methods
5959
def __init__(
6060
self,
6161
network,
@@ -213,6 +213,21 @@ def add_text(
213213

214214
# pylint: enable=too-many-arguments
215215

216+
def remove_all_text(self, clear_font_cache=False):
217+
"""Remove all added text and labels.
218+
219+
:param bool clear_font_cache: Clear the font cache. Defaults to False.
220+
"""
221+
222+
# Remove the labels
223+
for i in range(len(self._text)):
224+
self.set_text("", i)
225+
# Remove the data
226+
self._text = []
227+
if clear_font_cache:
228+
self._fonts = {}
229+
gc.collect()
230+
216231
def set_text(self, val, index=0):
217232
"""Display text, with indexing into our list of text boxes.
218233

0 commit comments

Comments
 (0)