-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextLabel.py
45 lines (30 loc) · 1.33 KB
/
TextLabel.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
import pygame
from Colors import BLACK, AQUA
class TextLabel:
_FONT = 'freesansbold.ttf'
def __init__(self, height, position, value, surface):
self.height = height
self.x, self.y = self.position = position
self.value = value
self.surface = surface
self.color = BLACK
def show(self):
pygame.draw.ellipse(self.surface, AQUA, (self.x, self.y, self.height, 50))
customFont = pygame.font.Font(self._FONT, self.height)
textSurface = customFont.render(self.value, True, self.color)
textShape = textSurface.get_rect()
textShape.center = (self.position)
self.surface.blit(textSurface, textShape)
# class TextLabel(AppObject):
# _FONT = 'freesansbold.ttf'
# def __init__(self, height, position, text, color, screen, hover_func, click_func):
# self.height = height
# self.text = text
# self.color = color
# self.on_init(position, screen, hover_func, click_func)
# def show(self):
# customFont = pygame.font.Font(self._FONT, self.height)
# textSurface = customFont.render(self.text, True, self.color)
# textShape = textSurface.get_rect()
# textShape.center = (self.x, self.y)
# self.surface.blit(textSurface, textShape)