-
Notifications
You must be signed in to change notification settings - Fork 0
/
statusscreen.py
73 lines (63 loc) · 2.28 KB
/
statusscreen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
""" 9000 series system status screen display engine """
#!python3
import random
import string
import time
import pygame
# Init pygame
pygame.init()
# get screen res
screentraits = pygame.display.Info()
wres = screentraits.current_w
hres = screentraits.current_h
screen = pygame.display.set_mode([wres, hres], pygame.FULLSCREEN)
white = [200, 200, 200]
min_time = 5
sysstrings = ('COM', 'VEH', 'NAV', 'GDE', 'CNT', 'NUC', 'ATM', 'HIB', 'DMG',
'FLX', 'LIF', 'MEM', 'DMC')
sysbgcolors = ('#993366', '#00008b', '#00008b', '#000099', '#006600', '#00008b',
'#950000', '#006600', '#aa0114', '#000099', '#950000', '#3333ff', '#800020')
sysentry = 0
def sub_text():
""" generate random subtext """
tlb1 = random.choice(string.ascii_uppercase)
tlb2 = random.choice(string.ascii_uppercase)
tlb3 = random.choice(string.ascii_uppercase)
ftl1 = random.choice(string.hexdigits)
ftl2 = random.choice(string.hexdigits)
stl1 = random.choice(string.hexdigits)
stl2 = random.choice(string.hexdigits)
sub_string = tlb1 + tlb2 + tlb3 + ": " + ftl1 + ftl2 + " - " + stl1 + stl2
return str(sub_string)
def set_bgcolor(bgcolor):
""" fill the screen with a color. """
pygame.display.flip()
screen.fill(pygame.Color(bgcolor))
pygame.display.update()
def add_text(text_string):
""" write the text to display. """
font = pygame.font.SysFont("moki", int(wres / 8), bold=True)
text = font.render(text_string, True, white)
text_rect = text.get_rect(center=(int(wres / 2), int(hres / 2 + (wres / 40))))
screen.blit(text, text_rect)
pygame.display.update()
def add_subtext():
""" add sub-text to display. """
st = sub_text()
font = pygame.font.SysFont("moki", int(wres / 64), bold=True)
text = font.render(st, True, white)
text_rect = text.get_rect(center=(int(wres / 5), int(hres / 2 - (wres / 20))))
screen.blit(text, text_rect)
pygame.display.update()
while True:
next_sys = random.randint(0, 12)
if next_sys == sysentry:
next_sys = sysentry + 1
sysitem = sysstrings[next_sys]
set_bgcolor(sysbgcolors[next_sys])
print(sysbgcolors[next_sys])
sep = " "
add_text(sep.join(sysitem))
add_subtext()
display_time = random.randint(0, 15) + min_time
time.sleep(display_time)