Skip to content

Commit f4ec7bd

Browse files
authored
Merge pull request #10 from makermelissa/main
Moved text wrapping to set_text()
2 parents 7a0b303 + 40f068b commit f4ec7bd

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

adafruit_magtag/magtag.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ def set_text(self, val, index=0, auto_refresh=True):
249249
string += "..."
250250
index_in_splash = None
251251

252+
if len(string) > 0 and self._text_wrap[index]:
253+
if self._debug:
254+
print("Wrapping text with length of", self._text_wrap[index])
255+
lines = self.wrap_nicely(string, self._text_wrap[index])
256+
string = "\n".join(lines)
257+
252258
if self._text[index] is not None:
253259
if self._debug:
254260
print("Replacing text area with :", string)
@@ -356,13 +362,6 @@ def fetch(self, refresh_url=None, timeout=10):
356362
string = "{:,d}".format(int(values[i]))
357363
except (TypeError, ValueError):
358364
string = values[i] # ok its a string
359-
if self._debug:
360-
print("Drawing text", string)
361-
if self._text_wrap[i]:
362-
if self._debug:
363-
print("Wrapping text with length of", self._text_wrap[i])
364-
lines = self.wrap_nicely(string, self._text_wrap[i])
365-
string = "\n".join(lines)
366365
self.set_text(string, index=i, auto_refresh=False)
367366
self.refresh()
368367
if len(values) == 1:

0 commit comments

Comments
 (0)