Skip to content
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
27 changes: 9 additions & 18 deletions adafruit_display_text/text_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ class TextBox(bitmap_label.Label):
DYNAMIC_HEIGHT = const(-1)

def __init__(
self, font: FontProtocol, width: int, height: int, align=ALIGN_LEFT, **kwargs
self,
font: FontProtocol,
width: int,
height: int,
align=ALIGN_LEFT,
**kwargs,
) -> None:
self._bitmap = None
self._tilegrid = None
Expand Down Expand Up @@ -238,23 +243,9 @@ def _reset_text(
self._text = self._replace_tabs(text)

# Check for empty string
if (not text) or (
text is None
): # If empty string, just create a zero-sized bounding box and that's it.
self._bounding_box = (
0,
0,
0, # zero width with text == ""
0, # zero height with text == ""
)
# Clear out any items in the self._local_group Group, in case this is an
# update to the bitmap_label
for _ in self._local_group:
self._local_group.pop(0)

# Free the bitmap and tilegrid since they are removed
self._bitmap = None
self._tilegrid = None
if (not text) or (text is None):
# clear the existing bitmap and keep it
self._bitmap.fill(0)

else: # The text string is not empty, so create the Bitmap and TileGrid and
# append to the self Group
Expand Down