Skip to content

Commit f049812

Browse files
committed
always show textbox when empty
1 parent 469e24d commit f049812

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

adafruit_display_text/text_box.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class TextBox(bitmap_label.Label):
5454
:param height: The height of the TextBox in pixels.
5555
:param align: How to align the text within the box,
5656
valid values are ``ALIGN_LEFT``, ``ALIGN_CENTER``, ``ALIGN_RIGHT``.
57-
:param bool show_when_empty: Whether to show the background box
58-
when there is no text. True to show when empty, False to hide.
5957
"""
6058

6159
ALIGN_LEFT = const(0)
@@ -70,14 +68,12 @@ def __init__(
7068
width: int,
7169
height: int,
7270
align=ALIGN_LEFT,
73-
show_when_empty=False,
7471
**kwargs,
7572
) -> None:
7673
self._bitmap = None
7774
self._tilegrid = None
7875
self._prev_label_direction = None
7976
self._width = width
80-
self._show_when_empty = show_when_empty
8177

8278
if height != TextBox.DYNAMIC_HEIGHT:
8379
self._height = height
@@ -248,25 +244,8 @@ def _reset_text(
248244

249245
# Check for empty string
250246
if (not text) or (text is None):
251-
if not self._show_when_empty:
252-
# If empty string, just create a zero-sized bounding box and that's it.
253-
self._bounding_box = (
254-
0,
255-
0,
256-
0, # zero width with text == ""
257-
0, # zero height with text == ""
258-
)
259-
# Clear out any items in the self._local_group Group, in case this is an
260-
# update to the bitmap_label
261-
for _ in self._local_group:
262-
self._local_group.pop(0)
263-
264-
# Free the bitmap and tilegrid since they are removed
265-
self._bitmap = None
266-
self._tilegrid = None
267-
else:
268-
# clear the existing bitmap and keep it
269-
self._bitmap.fill(0)
247+
# clear the existing bitmap and keep it
248+
self._bitmap.fill(0)
270249

271250
else: # The text string is not empty, so create the Bitmap and TileGrid and
272251
# append to the self Group
@@ -411,14 +390,3 @@ def align(self, align: int) -> None:
411390
if align not in {TextBox.ALIGN_LEFT, TextBox.ALIGN_CENTER, TextBox.ALIGN_RIGHT}:
412391
raise ValueError("Align must be one of: ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT")
413392
self._align = align
414-
415-
@property
416-
def show_when_empty(self):
417-
"""
418-
Whether to show the background box when there is no text
419-
"""
420-
return self._show_when_empty
421-
422-
@show_when_empty.setter
423-
def show_when_empty(self, value: bool) -> None:
424-
self._show_when_empty = value

0 commit comments

Comments
 (0)