Skip to content

Commit 2063412

Browse files
committed
remove the background tilegrid when not in use. Don't add background tilegrid inside init
1 parent fdd5bd8 commit 2063412

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

adafruit_display_text/label.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ def __init__(
113113
self._background_color = background_color
114114
self._background_palette = displayio.Palette(1)
115115
self._added_background_tilegrid = False
116-
if self._background_color:
117-
self.append(
118-
displayio.TileGrid(
119-
displayio.Bitmap(1, 1, 1), pixel_shader=self._background_palette
120-
)
121-
) # initialize with a blank tilegrid placeholder for background
122-
self._added_background_tilegrid = True
123116

124117
self._padding_top = padding_top
125118
self._padding_bottom = padding_bottom
@@ -180,6 +173,8 @@ def _update_background_color(self, new_color):
180173

181174
if new_color is None:
182175
self._background_palette.make_transparent(0)
176+
self.pop(0)
177+
self._added_background_tilegrid = False
183178
else:
184179
self._background_palette.make_opaque(0)
185180
self._background_palette[0] = new_color
@@ -194,7 +189,6 @@ def _update_background_color(self, new_color):
194189
)
195190
lines = self.text.count("\n") + 1
196191
if not self._added_background_tilegrid:
197-
198192
self._added_background_tilegrid = True
199193
self.insert(0, self._create_background_box(lines, y_offset))
200194
else:
@@ -295,7 +289,6 @@ def _update_text(
295289
and len(new_text) + self._padding_left + self._padding_right > 0
296290
):
297291
if not self._added_background_tilegrid:
298-
299292
self._added_background_tilegrid = True
300293
self.insert(0, self._create_background_box(lines, y_offset))
301294
else:

0 commit comments

Comments
 (0)