Skip to content

Commit a2fdbe1

Browse files
authored
Merge pull request #20 from makermelissa/master
Deal with empty strings properly
2 parents 7a59a76 + 339bc32 commit a2fdbe1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

adafruit_matrixportal/matrixportal.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,20 @@ def set_text(self, val, index=0):
258258
if self._text[index] is not None:
259259
print("Replacing text area with :", string)
260260
index_in_splash = self.splash.index(self._text[index])
261-
self._text[index] = Label(self._text_font, text=string)
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]
261+
if len(string) > 0:
262+
self._text[index] = Label(self._text_font, text=string)
263+
self._text[index].color = self._text_color[index]
264+
self._text[index].x = self._text_position[index][0]
265+
self._text[index].y = self._text_position[index][1]
266+
elif index_in_splash is not None:
267+
self._text[index] = None
265268

266269
if index_in_splash is not None:
267-
self.splash[index_in_splash] = self._text[index]
268-
else:
270+
if self._text[index] is not None:
271+
self.splash[index_in_splash] = self._text[index]
272+
else:
273+
del self.splash[index_in_splash]
274+
elif self._text[index] is not None:
269275
self.splash.append(self._text[index])
270276

271277
def get_local_time(self, location=None):

0 commit comments

Comments
 (0)