Skip to content

save color even if text doesn't exist yet for index #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions adafruit_matrixportal/matrixportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,16 @@ def set_text_color(self, color, index=0):
:param index: Defaults to 0.

"""
if self._text[index]:
color = self.html_color_convert(color)
self._text_color[index] = color
self._text[index].color = color
if 0 <= index < len(self._text_color):
self._text_color[index] = self.html_color_convert(color)
if self._text[index] is not None:
self._text[index].color = self._text_color[index]
else:
raise IndexError(
"index {} is out of bounds. Please call add_text() and set_text() first.".format(
index
)
)

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