-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.py
49 lines (41 loc) · 1.88 KB
/
log.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
#################################################################################
# #
# log.py #
# #
#################################################################################
# #
# Esse arquivo contem as definicoes da classe Log. #
# #
#################################################################################
import pygame
from time import gmtime, strftime
from pygame.locals import *
from colors import *
class Log:
background_color = white
font_color = black
border_color = black
border_thickness = 1
# Inicializa a classe
#
# @in window: janela principal
# @in rect: rect do objeto
# @in font_rect: rect do texto
def __init__(self, window, rect, font_rect):
self.window = window
self.rect = rect
self.font_rect = font_rect
self.font = pygame.font.Font(None, 17)
# Pinta a janela do log com o texto do evento
def paint(self):
pygame.draw.rect(self.window, self.background_color, self.rect)
pygame.draw.rect(self.window, self.border_color, self.rect, self.border_thickness)
self.window.blit(self.font.render(self.text, 1, self.font_color), self.font_rect)
# Atualiza as mensagens de log.
#
# @in text: texto a ser inserido.
def update(self, text):
self.text = text
with open('/log.txt','a') as file:
file.write( "[" + strftime("%Y-%m-%d %H:%M:%S", gmtime()) + "]" + ":::" + text + "\n")
file.close()