diff --git a/pg.py b/pg.py index 41edede..a0f822a 100644 --- a/pg.py +++ b/pg.py @@ -98,23 +98,24 @@ class Button: class TextButton: def __init__(self, text: str, position: Union[tuple, Callable], surface: pygame.Surface, function=None, key: int=0, text_color: tuple=white, bg_color: tuple=gray, font: pygame.font.Font=default_font, padding: int=8): - self.text_object = self.generate_text(text) - self.text = text + self.text_color = text_color + self.font = font + + self.text_object = self.generate_text(text) + self.size = (self.text_object.get_width() + padding * 2, self.text_object.get_height() + padding * 2) + self.surface = surface self.function = function - self.text_color = text_color self.bg_color = bg_color - self.font = font self.padding = padding - self.callable_position = None if position is int: self.position = position else: - self.position = position() + self.position = position(size=self.size) self.callable_position = position self.background = self.generate_background()