Made the changes in the latest commit work.

This commit is contained in:
The Wobbler 2023-11-06 20:18:07 +01:00
parent 542e6b39ca
commit 57ded2ff83

5
pg.py
View file

@ -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: