From 57ded2ff839e18dd3556bf28cbcec62148cba116 Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Mon, 6 Nov 2023 20:18:07 +0100 Subject: [PATCH] Made the changes in the latest commit work. --- pg.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pg.py b/pg.py index f734b0a..41edede 100644 --- a/pg.py +++ b/pg.py @@ -98,6 +98,8 @@ 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.surface = surface self.function = function @@ -115,7 +117,6 @@ class TextButton: self.position = position() self.callable_position = position - self.text_object = self.generate_text(text) self.background = self.generate_background() self.button = Button(function, self.background, key=key) @@ -129,7 +130,7 @@ class TextButton: w, h = self.text_object.get_size() w, h = w + self.padding * 2, h + self.padding * 2 - return pygame.Rect(self.pos, (w, h)) + return pygame.Rect(self.position, (w, h)) def update(self, new_text: str=None, new_pos: Union[tuple, Callable]=None, new_surface: pygame.Surface=None, new_func=None, new_key: int=None, new_text_color: tuple=None, new_bg_color: tuple=None, new_font: pygame.font.Font=None, new_padding: int=None): if new_text is None: