Skip to content

Commit 2aefd1a

Browse files
authored
Merge pull request #233 from FoamyGuy/textbox_show_when_empty
TextBox show when empty
2 parents 969fe01 + f049812 commit 2aefd1a

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

adafruit_display_text/text_box.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ class TextBox(bitmap_label.Label):
6363
DYNAMIC_HEIGHT = const(-1)
6464

6565
def __init__(
66-
self, font: FontProtocol, width: int, height: int, align=ALIGN_LEFT, **kwargs
66+
self,
67+
font: FontProtocol,
68+
width: int,
69+
height: int,
70+
align=ALIGN_LEFT,
71+
**kwargs,
6772
) -> None:
6873
self._bitmap = None
6974
self._tilegrid = None
@@ -238,23 +243,9 @@ def _reset_text(
238243
self._text = self._replace_tabs(text)
239244

240245
# Check for empty string
241-
if (not text) or (
242-
text is None
243-
): # If empty string, just create a zero-sized bounding box and that's it.
244-
self._bounding_box = (
245-
0,
246-
0,
247-
0, # zero width with text == ""
248-
0, # zero height with text == ""
249-
)
250-
# Clear out any items in the self._local_group Group, in case this is an
251-
# update to the bitmap_label
252-
for _ in self._local_group:
253-
self._local_group.pop(0)
254-
255-
# Free the bitmap and tilegrid since they are removed
256-
self._bitmap = None
257-
self._tilegrid = None
246+
if (not text) or (text is None):
247+
# clear the existing bitmap and keep it
248+
self._bitmap.fill(0)
258249

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

0 commit comments

Comments
 (0)