Skip to content

Commit a23dab9

Browse files
committed
restore examples
1 parent 5fd70e8 commit a23dab9

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SPDX-FileCopyrightText: 2021 Tim C, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Make green and purple rectangles and a
6+
"Hello World" label. Displayed with Blinka_Displayio_PyGameDisplay
7+
"""
8+
import displayio
9+
import terminalio
10+
from adafruit_display_text import label
11+
from blinka_displayio_pygamedisplay import PyGameDisplay
12+
13+
14+
# Make the display context. Change size if you want
15+
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
16+
17+
display = PyGameDisplay(width=320, height=240)
18+
main_group = displayio.Group(max_size=10)
19+
display.show(main_group)
20+
21+
layout = GridLayout(
22+
x=10,
23+
y=10,
24+
width=320,
25+
height=100,
26+
grid_size=(2, 2),
27+
cell_padding=8,
28+
)
29+
_labels = []
30+
31+
_labels.append(
32+
label.Label(
33+
terminalio.FONT, scale=2, x=0, y=0, text="Hello", background_color=0x770077
34+
)
35+
)
36+
layout.add_content(_labels[0], grid_position=(0, 0), cell_size=(1, 1))
37+
_labels.append(
38+
label.Label(
39+
terminalio.FONT, scale=2, x=0, y=0, text="World", background_color=0x007700
40+
)
41+
)
42+
layout.add_content(_labels[1], grid_position=(1, 0), cell_size=(1, 1))
43+
_labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Hello"))
44+
layout.add_content(_labels[2], grid_position=(0, 1), cell_size=(1, 1))
45+
_labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Grid"))
46+
layout.add_content(_labels[3], grid_position=(1, 1), cell_size=(1, 1))
47+
48+
main_group.append(layout)
49+
while display.running:
50+
pass
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SPDX-FileCopyrightText: 2021 Tim C, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Make green and purple rectangles and a
6+
"Hello World" label.
7+
"""
8+
import board
9+
import displayio
10+
import terminalio
11+
from adafruit_display_text import label
12+
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
13+
14+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
15+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
16+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
17+
display = board.DISPLAY
18+
19+
# Make the display context
20+
main_group = displayio.Group(max_size=10)
21+
display.show(main_group)
22+
23+
layout = GridLayout(
24+
x=10,
25+
y=10,
26+
width=200,
27+
height=100,
28+
grid_size=(2, 2),
29+
cell_padding=8,
30+
max_size=10,
31+
)
32+
_labels = []
33+
34+
_labels.append(
35+
label.Label(
36+
terminalio.FONT, scale=2, x=0, y=0, text="Hello", background_color=0x770077
37+
)
38+
)
39+
layout.add_content(_labels[0], grid_position=(0, 0), cell_size=(1, 1))
40+
_labels.append(
41+
label.Label(
42+
terminalio.FONT, scale=2, x=0, y=0, text="World", background_color=0x007700
43+
)
44+
)
45+
layout.add_content(_labels[1], grid_position=(1, 0), cell_size=(1, 1))
46+
_labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Hello"))
47+
layout.add_content(_labels[2], grid_position=(0, 1), cell_size=(1, 1))
48+
_labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Grid"))
49+
layout.add_content(_labels[3], grid_position=(1, 1), cell_size=(1, 1))
50+
51+
main_group.append(layout)
52+
while True:
53+
pass
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-FileCopyrightText: 2021 Tim C, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Currently contains GridLayout example.
6+
7+
Make green and purple rectangles and a
8+
"Hello World" label.
9+
"""
10+
import board
11+
import displayio
12+
import terminalio
13+
from adafruit_display_text import label
14+
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
15+
16+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
17+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
18+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
19+
display = board.DISPLAY
20+
21+
# Make the display context
22+
main_group = displayio.Group(max_size=10)
23+
display.show(main_group)
24+
25+
layout = GridLayout(
26+
x=10,
27+
y=10,
28+
width=200,
29+
height=100,
30+
grid_size=(2, 2),
31+
cell_padding=8,
32+
max_size=10,
33+
)
34+
_labels = []
35+
36+
_labels.append(
37+
label.Label(
38+
terminalio.FONT, scale=2, x=0, y=0, text="Hello", background_color=0x770077
39+
)
40+
)
41+
layout.add_content(_labels[0], grid_position=(0, 0), cell_size=(1, 1))
42+
_labels.append(
43+
label.Label(
44+
terminalio.FONT, scale=2, x=0, y=0, text="World", background_color=0x007700
45+
)
46+
)
47+
layout.add_content(_labels[1], grid_position=(1, 0), cell_size=(1, 1))
48+
_labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Hello"))
49+
layout.add_content(_labels[2], grid_position=(0, 1), cell_size=(1, 1))
50+
_labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Grid"))
51+
layout.add_content(_labels[3], grid_position=(1, 1), cell_size=(1, 1))
52+
53+
main_group.append(layout)
54+
while True:
55+
pass

0 commit comments

Comments
 (0)