|
2 | 2 | # SPDX-License-Identifier: MIT |
3 | 3 |
|
4 | 4 | """ |
5 | | -This examples shows the use of base_alignment parameter. |
| 5 | +This example shows the use of base_alignment parameter. |
6 | 6 | """ |
7 | 7 |
|
8 | | -import time |
9 | 8 | import board |
10 | 9 | import displayio |
11 | 10 | from adafruit_bitmap_font import bitmap_font |
|
21 | 20 | TEXT_RIGHT = "MG" |
22 | 21 | TEXT_LEFT = "32.47" |
23 | 22 |
|
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() |
39 | 24 |
|
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) |
49 | 37 |
|
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) |
53 | 48 |
|
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) |
57 | 60 |
|
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 | +) |
68 | 70 |
|
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) |
83 | 73 |
|
| 74 | +while True: |
| 75 | + pass |
0 commit comments