Skip to content

Commit 8ca3c1a

Browse files
committed
remove unneeded prints, make the 'text' variable more like a constant. moving text_group setup code all together. cleanup some whitespace.
1 parent afeb2a2 commit 8ca3c1a

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

examples/display_text_anchored_position.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,45 @@
88

99
DISPLAY_WIDTH = 320
1010
DISPLAY_HEIGHT = 240
11+
TEXT = "Hello"
1112

12-
text_group = displayio.Group(max_size=9)
13-
text = "Hello"
14-
text_area_top_left = label.Label(terminalio.FONT, text=text)
13+
text_area_top_left = label.Label(terminalio.FONT, text=TEXT)
1514
text_area_top_left.anchor_point = (0.0, 0.0)
1615
text_area_top_left.anchored_position = (10, 10)
1716

18-
text_area_top_middle = label.Label(terminalio.FONT, text=text)
17+
text_area_top_middle = label.Label(terminalio.FONT, text=TEXT)
1918
text_area_top_middle.anchor_point = (0.5, 0.0)
2019
text_area_top_middle.anchored_position = (DISPLAY_WIDTH/2, 10)
2120

22-
text_area_top_right = label.Label(terminalio.FONT, text=text)
21+
text_area_top_right = label.Label(terminalio.FONT, text=TEXT)
2322
text_area_top_right.anchor_point = (1.0, 0.0)
2423
text_area_top_right.anchored_position = (DISPLAY_WIDTH-10, 10)
2524

26-
text_area_middle_left = label.Label(terminalio.FONT, text=text)
25+
text_area_middle_left = label.Label(terminalio.FONT, text=TEXT)
2726
text_area_middle_left.anchor_point = (0.0, 0.5)
28-
text_area_middle_left.anchored_position = (10,DISPLAY_HEIGHT/2)
27+
text_area_middle_left.anchored_position = (10, DISPLAY_HEIGHT/2)
2928

30-
text_area_middle_middle = label.Label(terminalio.FONT, text=text)
29+
text_area_middle_middle = label.Label(terminalio.FONT, text=TEXT)
3130
text_area_middle_middle.anchor_point = (0.5, 0.5)
32-
text_area_middle_middle.anchored_position = (DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2)
31+
text_area_middle_middle.anchored_position = (DISPLAY_WIDTH/2, DISPLAY_HEIGHT/2)
3332

34-
text_area_middle_right = label.Label(terminalio.FONT, text=text)
33+
text_area_middle_right = label.Label(terminalio.FONT, text=TEXT)
3534
text_area_middle_right.anchor_point = (1.0, 0.5)
3635
text_area_middle_right.anchored_position = (DISPLAY_WIDTH-10, DISPLAY_HEIGHT/2)
3736

38-
39-
text_area_bottom_left = label.Label(terminalio.FONT, text=text)
37+
text_area_bottom_left = label.Label(terminalio.FONT, text=TEXT)
4038
text_area_bottom_left.anchor_point = (0.0, 1.0)
4139
text_area_bottom_left.anchored_position = (10, DISPLAY_HEIGHT)
4240

43-
text_area_bottom_middle = label.Label(terminalio.FONT, text=text)
41+
text_area_bottom_middle = label.Label(terminalio.FONT, text=TEXT)
4442
text_area_bottom_middle.anchor_point = (0.5, 1.0)
4543
text_area_bottom_middle.anchored_position = (DISPLAY_WIDTH/2, DISPLAY_HEIGHT)
4644

47-
text_area_bottom_right = label.Label(terminalio.FONT, text=text)
45+
text_area_bottom_right = label.Label(terminalio.FONT, text=TEXT)
4846
text_area_bottom_right.anchor_point = (1.0, 1.0)
4947
text_area_bottom_right.anchored_position = (DISPLAY_WIDTH-10, DISPLAY_HEIGHT)
5048

49+
text_group = displayio.Group(max_size=9)
5150
text_group.append(text_area_top_middle)
5251
text_group.append(text_area_top_left)
5352
text_group.append(text_area_top_right)
@@ -58,9 +57,6 @@
5857
text_group.append(text_area_bottom_left)
5958
text_group.append(text_area_bottom_right)
6059

61-
print(text_area_top_right.anchored_position)
62-
print(text_area_top_right.anchor_point)
63-
6460
board.DISPLAY.show(text_group)
6561

6662
while True:

0 commit comments

Comments
 (0)