From 339bc32dd4e2714a6152c7d5310f8a75aebd6987 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 21 Sep 2020 10:46:54 -0600 Subject: [PATCH] Deal with empty strings properly --- adafruit_matrixportal/matrixportal.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/adafruit_matrixportal/matrixportal.py b/adafruit_matrixportal/matrixportal.py index 95608a2..e62c2a8 100755 --- a/adafruit_matrixportal/matrixportal.py +++ b/adafruit_matrixportal/matrixportal.py @@ -258,14 +258,20 @@ def set_text(self, val, index=0): if self._text[index] is not None: print("Replacing text area with :", string) index_in_splash = self.splash.index(self._text[index]) - self._text[index] = Label(self._text_font, text=string) - self._text[index].color = self._text_color[index] - self._text[index].x = self._text_position[index][0] - self._text[index].y = self._text_position[index][1] + if len(string) > 0: + self._text[index] = Label(self._text_font, text=string) + self._text[index].color = self._text_color[index] + self._text[index].x = self._text_position[index][0] + self._text[index].y = self._text_position[index][1] + elif index_in_splash is not None: + self._text[index] = None if index_in_splash is not None: - self.splash[index_in_splash] = self._text[index] - else: + if self._text[index] is not None: + self.splash[index_in_splash] = self._text[index] + else: + del self.splash[index_in_splash] + elif self._text[index] is not None: self.splash.append(self._text[index]) def get_local_time(self, location=None):