Skip to content

Commit 013d0d6

Browse files
authored
Merge pull request #35 from tannewt/group_subscr
Use Group subscription to replace text
2 parents 763d5a3 + 17bc358 commit 013d0d6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

adafruit_pyportal.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,19 +478,19 @@ def set_text(self, val, index=0):
478478
# print("Replacing text area with :", string)
479479
# self._text[index].text = string
480480
# return
481-
items = []
482-
while len(self.splash): # pylint: disable=len-as-condition
483-
item = self.splash.pop()
484-
if item == self._text[index]:
485-
break
486-
items.append(item)
481+
try:
482+
text_index = self.splash.index(self._text[index])
483+
except AttributeError:
484+
for i in range(len(self.splash)):
485+
if self.splash[i] == self._text[index]:
486+
text_index = i
487+
break
488+
487489
self._text[index] = Label(self._text_font, text=string)
488490
self._text[index].color = self._text_color[index]
489491
self._text[index].x = self._text_position[index][0]
490492
self._text[index].y = self._text_position[index][1]
491-
self.splash.append(self._text[index])
492-
for g in items:
493-
self.splash.append(g)
493+
self.splash[text_index] = self._text[index]
494494
return
495495

496496
if self._text_position[index]: # if we want it placed somewhere...

0 commit comments

Comments
 (0)