Skip to content

Instantly share code, notes, and snippets.

@jdc-cunningham
Created May 10, 2023 20:11
Show Gist options
  • Save jdc-cunningham/117a4e38177043c03631d711db94691b to your computer and use it in GitHub Desktop.
Save jdc-cunningham/117a4e38177043c03631d711db94691b to your computer and use it in GitHub Desktop.
import display
import time
disp_object = []
def display_article(title, lines):
global disp_objects
y_pos = 24
t = display.Text(f'{title}', 0, 24, display.BLUE, justify=display.MIDDLE_LEFT)
l1 = display.Text(lines[0] if 0 < len(lines) else '', 0, y_pos + 50, display.WHITE, justify=display.MIDDLE_LEFT)
l2 = display.Text(lines[1] if 1 < len(lines) else '', 0, y_pos + 100, display.WHITE, justify=display.MIDDLE_LEFT)
l3 = display.Text(lines[2] if 2 < len(lines) else '', 0, y_pos + 150, display.WHITE, justify=display.MIDDLE_LEFT)
l4 = display.Text(lines[3] if 3 < len(lines) else '', 0, y_pos + 200, display.WHITE, justify=display.MIDDLE_LEFT)
l5 = display.Text(lines[4] if 4 < len(lines) else '', 0, y_pos + 250, display.WHITE, justify=display.MIDDLE_LEFT)
l6 = display.Text(lines[5] if 5 < len(lines) else '', 0, y_pos + 300, display.WHITE, justify=display.MIDDLE_LEFT)
l7 = display.Text(lines[6] if 6 < len(lines) else '', 0, y_pos + 350, display.WHITE, justify=display.MIDDLE_LEFT)
disp_objects = [t, l1, l2, l3, l4, l5, l6, l7]
display.show([t, l1, l2, l3, l4, l5, l6, l7])
articles = [
{
"title": "title 1",
"comment": [
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz"
]
},
{
"title": "title 2",
"comment": [
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz"
]
},
{
"title": "title 3",
"comment": [
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz"
]
}
]
display_article(articles[0]['title'], articles[0]['comment'])
time.sleep(3)
articles.pop(0)
display_article(articles[0]['title'], articles[0]['comment'])
time.sleep(3)
articles.pop(0)
display_article(articles[0]['title'], articles[0]['comment'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment