Skip to content

Commit 8f9e16e

Browse files
committed
Scott's update plus bugfix
1 parent af1c7d8 commit 8f9e16e

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

adafruit_matrixportal/matrixportal.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -251,27 +251,19 @@ def set_text(self, val, index=0):
251251
if self._text_maxlen[index]:
252252
string = string[: self._text_maxlen[index]]
253253
print("text index", self._text[index])
254+
index_in_splash = None
254255
if self._text[index] is not None:
255256
print("Replacing text area with :", string)
256257
self._text[index].text = string
257-
text_index = self.splash.index(self._text[index])
258-
259-
self._text[index] = Label(
260-
self._text_font, text=string, max_glyphs=max_glyphs
261-
)
262-
self._text[index].color = self._text_color[index]
263-
self._text[index].x = self._text_position[index][0]
264-
self._text[index].y = self._text_position[index][1]
265-
self.splash[text_index] = self._text[index]
266-
267-
elif self._text_position[index]: # if we want it placed somewhere...
268-
print("Making text area with string:", string)
269-
self._text[index] = Label(
270-
self._text_font, text=string, max_glyphs=max_glyphs
271-
)
272-
self._text[index].color = self._text_color[index]
273-
self._text[index].x = self._text_position[index][0]
274-
self._text[index].y = self._text_position[index][1]
258+
index_in_splash = self.splash.index(self._text[index])
259+
self._text[index] = Label(self._text_font, text=string, max_glyphs=max_glyphs)
260+
self._text[index].color = self._text_color[index]
261+
self._text[index].x = self._text_position[index][0]
262+
self._text[index].y = self._text_position[index][1]
263+
264+
if index_in_splash is not None:
265+
self.splash[index_in_splash] = self._text[index]
266+
else:
275267
self.splash.append(self._text[index])
276268

277269
def get_local_time(self, location=None):

0 commit comments

Comments
 (0)