Skip to content

Commit a7101c8

Browse files
committed
New Example logic to show parameters cases at the same time
1 parent ac3f4b7 commit a7101c8

File tree

1 file changed

+48
-56
lines changed

1 file changed

+48
-56
lines changed

examples/display_text_label_align_baseline_comparison.py

Lines changed: 48 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
# SPDX-License-Identifier: MIT
33

44
"""
5-
This examples shows the use of base_alignment parameter.
5+
This example shows the use of base_alignment parameter.
66
"""
77

8-
import time
98
import board
109
import displayio
1110
from adafruit_bitmap_font import bitmap_font
@@ -21,63 +20,56 @@
2120
TEXT_RIGHT = "MG"
2221
TEXT_LEFT = "32.47"
2322

24-
while True:
25-
main_group = displayio.Group()
26-
print("Base Alignment parameter False")
27-
28-
# Create label
29-
left_text = label.Label(
30-
BIG_FONT,
31-
text=TEXT_LEFT,
32-
color=0x000000,
33-
background_color=0x999999,
34-
x=10,
35-
y=50,
36-
base_alignment=False,
37-
)
38-
main_group.append(left_text)
23+
main_group = displayio.Group()
3924

40-
right_text = label.Label(
41-
MEDIUM_FONT,
42-
text=TEXT_RIGHT,
43-
color=0x000000,
44-
background_color=0x999999,
45-
x=80,
46-
y=50,
47-
base_alignment=False
48-
)
25+
# Create labels
26+
# Base Alignment parameter False
27+
left_text = label.Label(
28+
BIG_FONT,
29+
text=TEXT_LEFT,
30+
color=0x000000,
31+
background_color=0x999999,
32+
x=10,
33+
y=50,
34+
base_alignment=False,
35+
)
36+
main_group.append(left_text)
4937

50-
main_group.append(right_text)
51-
display.show(main_group)
52-
display.refresh()
38+
right_text = label.Label(
39+
MEDIUM_FONT,
40+
text=TEXT_RIGHT,
41+
color=0x000000,
42+
background_color=0x999999,
43+
x=80,
44+
y=50,
45+
base_alignment=False
46+
)
47+
main_group.append(right_text)
5348

54-
time.sleep(1)
55-
main_group = displayio.Group()
56-
print("Base Alignment parameter True")
49+
# Base Alignment parameter True
50+
left_text_aligned = label.Label(
51+
BIG_FONT,
52+
text=TEXT_LEFT,
53+
color=0x000000,
54+
background_color=0x999999,
55+
x=10,
56+
y=100,
57+
base_alignment=True
58+
)
59+
main_group.append(left_text_aligned)
5760

58-
left_text_aligned = label.Label(
59-
BIG_FONT,
60-
text=TEXT_LEFT,
61-
color=0x000000,
62-
background_color=0x999999,
63-
x=10,
64-
y=50,
65-
base_alignment=True
66-
)
67-
main_group.append(left_text_aligned)
61+
right_text_aligned = label.Label(
62+
MEDIUM_FONT,
63+
text=TEXT_RIGHT,
64+
color=0x000000,
65+
background_color=0x999999,
66+
x=80,
67+
y=100,
68+
base_alignment=True
69+
)
6870

69-
right_text_aligned = label.Label(
70-
MEDIUM_FONT,
71-
text=TEXT_RIGHT,
72-
color=0x000000,
73-
background_color=0x999999,
74-
x=80,
75-
y=50,
76-
base_alignment=True
77-
)
78-
79-
main_group.append(right_text_aligned)
80-
display.show(main_group)
81-
display.refresh()
82-
time.sleep(1)
71+
main_group.append(right_text_aligned)
72+
display.show(main_group)
8373

74+
while True:
75+
pass

0 commit comments

Comments
 (0)