-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiplay.py
65 lines (55 loc) · 1.87 KB
/
diplay.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
#!/usr/bin/python
# touchv5
# Texy 1/6/13
import pygame, sys, os, time
from pygame.locals import *
os.environ["SDL_FBDEV"] = "/dev/fb1"
pygame.init()
# set up the window
screen = pygame.display.set_mode((128, 160), 0, 32)
pygame.display.set_caption('Drawing')
# set up the colors
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = ( 0, 255, 0)
BLUE = ( 0, 0, 255)
CYAN = ( 0, 255, 255)
MAGENTA=(255, 0, 255)
YELLOW =(255, 255, 0)
# Fill background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill(WHITE)
box = pygame.draw.rect(background, YELLOW,(0, 0, 40, 240))
box = pygame.draw.rect(background, CYAN, (40, 0, 40, 240))
box = pygame.draw.rect(background, GREEN, (80, 0, 40, 240))
box = pygame.draw.rect(background,MAGENTA,(120, 0, 40, 240))
box = pygame.draw.rect(background, RED, (160, 0, 40, 240))
box = pygame.draw.rect(background, BLUE ,(200, 0, 40, 240))
box = pygame.draw.rect(background, BLACK ,(240, 0, 40, 240))
# Display some text
font = pygame.font.Font(None, 36)
text = font.render("Touch here", 1, (BLACK))
#text = pygame.transform.rotate(text,270)
textpos = text.get_rect(centerx=background.get_width()/2,centery=background.get_height()/2)
background.blit(text, textpos)
screen.blit(background, (0, 0))
pygame.display.flip()
running = True
# run the game loop
while running:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
print("Pos: %sx%s\n" % pygame.mouse.get_pos())
if textpos.collidepoint(pygame.mouse.get_pos()):
pygame.quit()
sys.exit()
running = False
elif event.type == KEYDOWN and event.key == K_ESCAPE:
running = False
pygame.display.update()