Skip to content

Commit 18db573

Browse files
committed
undo saving color if text not exist yet. raise error telling user the order to call the functions.
1 parent 606cd60 commit 18db573

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_matrixportal/matrixportal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ def set_text_color(self, color, index=0):
254254
:param index: Defaults to 0.
255255
256256
"""
257-
self._text_color[index] = color
258257
if self._text[index]:
259258
color = self.html_color_convert(color)
259+
self._text_color[index] = color
260260
self._text[index].color = color
261+
else:
262+
raise IndexError(f"index {index} is out of bounds. Please call add_text() and set_text() first.")
261263

262264
def set_text(self, val, index=0):
263265
"""Display text, with indexing into our list of text boxes.

0 commit comments

Comments
 (0)