Skip to content

Commit fe32558

Browse files
authored
Merge pull request #6 from jerryneedell/jerryn_fix_tilegrid
fix calls to displayio.TileGrid usage of position
2 parents 329158c + 739c904 commit fe32558

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

adafruit_display_text/label.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,26 @@ def _update_text(self, new_text): # pylint: disable=too-many-locals
101101
position_y = y - glyph.height - glyph.dy + y_offset
102102
position_x = x + glyph.dx
103103
if not self._text or old_c >= len(self._text) or character != self._text[old_c]:
104-
face = displayio.TileGrid(glyph.bitmap, pixel_shader=self.palette,
105-
default_tile=glyph.tile_index,
106-
tile_width=glyph.width, tile_height=glyph.height,
107-
position=(position_x, position_y))
104+
try:
105+
face = displayio.TileGrid(glyph.bitmap, pixel_shader=self.palette,
106+
default_tile=glyph.tile_index,
107+
tile_width=glyph.width, tile_height=glyph.height,
108+
position=(position_x, position_y))
109+
except TypeError:
110+
face = displayio.TileGrid(glyph.bitmap, pixel_shader=self.palette,
111+
default_tile=glyph.tile_index,
112+
tile_width=glyph.width, tile_height=glyph.height,
113+
x=position_x, y=position_y)
108114
if i < len(self):
109115
self[i] = face
110116
else:
111117
self.append(face)
112118
elif self._text and character == self._text[old_c]:
113-
self[i].position = (position_x, position_y)
119+
try:
120+
self[i].position = (position_x, position_y)
121+
except AttributeError:
122+
self[i].x = position_x
123+
self[i].y = position_y
114124

115125
x += glyph.shift_x
116126

0 commit comments

Comments
 (0)