Skip to content

Commit 3e22877

Browse files
authored
Merge pull request #1210 from jepler/sharpdisplay-example
CircuitPython_SharpDisplay_Displayio: work around a displaytext bug
2 parents b33ad19 + fd82450 commit 3e22877

File tree

1 file changed

+10
-2
lines changed
  • CircuitPython_SharpDisplay_Displayio

1 file changed

+10
-2
lines changed

CircuitPython_SharpDisplay_Displayio/code.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,15 @@ def sample(population, k):
231231
print(name)
232232
lines = name.split(" ")
233233
with BatchDisplayUpdate(display):
234-
names_font[0].text = lines[0]
235-
names_font[1].text = lines[1]
234+
for i in range(2):
235+
names_font[i].text = lines[i]
236+
237+
# Due to a bug in adafruit_display_text, we need to reestablish
238+
# the position of the labels when updating them.
239+
# Once https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/issues/82
240+
# has been resolved, this code will no longer be necessary (but
241+
# will not be harmful either)
242+
names_font[i].anchor_point = (0.5, 0)
243+
names_font[i].anchored_position = (200, i*84+42)
236244
time.sleep(5)
237245
names_font[0].text = names_font[1].text = ""

0 commit comments

Comments
 (0)