-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabel.py
More file actions
21 lines (17 loc) · 709 Bytes
/
Label.py
File metadata and controls
21 lines (17 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pygame
class Label:
def __init__(self, x, y, text, size, color=(255,255,255)):
self.x=x
self.y=y
self.text=text
self.size=size
self.font = pygame.font.SysFont("arial", size)
self.label=self.font.render(text, True, color)
label_rect=self.label.get_rect()
self.center=(label_rect[0]/2, label_rect[1]/2)
def set_text(self, text, color=(255,255,255)):
self.label=self.font.render(text, True, color)
def draw(self, win):
win.blit(self.label,
(self.x+(self.center[0] - self.label.get_width() // 2), self.y, self.label.get_width(),
self.label.get_height()))