@ -5,9 +5,9 @@ import pygame.camera
from pygame import *
def render_text_line ( image, color, font, text , pos = ( 0 , 0 ) ) :
render_text = font. render ( text , 1 , color)
image. blit ( render_text , pos )
def render_text_line ( r image, r color, r font, text , pos = ( 0 , 0 ) ) :
render_text = r font. render ( text , 1 , r color)
r image. blit ( render_text , pos )
class Screen :
@ -20,7 +20,8 @@ class Screen:
self . screen = pygame . display . set_mode ( self . size )
pygame . display . set_caption ( title )
def refresh ( self , rectangles = None ) :
@staticmethod
def refresh ( rectangles = None ) :
pygame . display . update ( rectangles )
def toggle_fullscreen ( self ) :
@ -45,12 +46,12 @@ class List(pygame.sprite.Sprite):
self . rect = self . image . get_rect ( )
self . rect . topleft = position
self . font = pygame . font . SysFont ( ' Arial ' , 25 )
self . di ct = { }
self . di splay_di ct = { }
self . updated = True
self . txtsize = self . font . size ( ' __||__ ' )
def set_dict ( self , dict) :
self . di ct = dict
def set_dict ( self , disp dict) :
self . di splay_dict = disp dict
self . updated = True
def update ( self ) :
@ -58,8 +59,8 @@ class List(pygame.sprite.Sprite):
height = 0
self . image . fill ( ( 0 , 0 , 0 ) )
for key in self . dict. keys ( ) :
line = ' {} : {} ' . format ( key, self . di ct[ key] )
for dict key in self . display_ dict. keys ( ) :
line = ' {} : {} ' . format ( dict key, self . di splay_di ct[ dict key] )
render_text_line ( self . image , ( 255 , 255 , 255 ) , self . font , line , ( 0 , height ) )
height + = self . txtsize [ 1 ]
@ -90,4 +91,4 @@ class PiCamera(pygame.sprite.Sprite):
self . output . truncate ( 0 )
self . camera . capture ( self . output , ' rgb ' , resize = self . camsize )
s = pygame . transform . rotate ( pygame . surfarray . make_surface ( self . output . array ) , 270 )
self . image . blit ( s , ( 0 , 0 ) )
self . image . blit ( s , ( 0 , 0 ) )