forked from tmwagency/pi-booth
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdisplay.py
67 lines (52 loc) · 1.39 KB
/
display.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
import sys
import time
#import and init pygame
import pygame
pygame.init()
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
basicFont = pygame.font.SysFont(None, 228)
count = 4
last_count_time = 0
infoObject = pygame.display.Info()
#create the screen
window = pygame.display.set_mode((640, 480))
pygame.display.set_caption('Hello world!')
def loop():
global count
global last_count_time
window.fill(WHITE)
if count == 0:
pass
elif time.time() - last_count_time >= 1:
count = count - 1
last_count_time = time.time()
#draw text
text = basicFont.render(str(count), True, BLACK)
textRect = text.get_rect()
textRect.left = (window.get_rect().centerx - 200)
textRect.centery = window.get_rect().centery
window.blit(text, textRect)
#draw it to the screen
pygame.display.flip()
def my_quit():
pygame.quit
sys.exit(0)
#input handling (somewhat boilerplate code):
while True:
loop()
for event in pygame.event.get():
if (event.type is pygame.KEYDOWN and event.key == pygame.K_ESCAPE) or event.type == pygame.QUIT :
my_quit()
if (event.type is pygame.KEYDOWN and event.key == pygame.K_f):
if window.get_flags() & pygame.FULLSCREEN:
pygame.display.set_mode((640, 480))
#loop()
else:
pygame.display.set_mode((infoObject.current_w, infoObject.current_h), pygame.FULLSCREEN)
#loop()
else:
print event