diff --git a/pg.py b/pg.py index 711eae9..c978cc6 100644 --- a/pg.py +++ b/pg.py @@ -97,13 +97,13 @@ 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): + 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: tuple=(8, 8)): 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.size = (self.text_object.get_width() + padding[0] * 2, self.text_object.get_height() + padding[1] * 2) self.surface = surface self.function = function @@ -129,11 +129,11 @@ class TextButton: def generate_background(self): w, h = self.text_object.get_size() - w, h = w + self.padding * 2, h + self.padding * 2 + w, h = w + self.padding[0] * 2, h + self.padding[1] * 2 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): + 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: tuple=None): if new_text is None: new_text = self.text @@ -157,7 +157,7 @@ class TextButton: self.text_object = self.generate_text(new_text) - self.size = (self.text_object.get_width() + self.padding * 2, self.text_object.get_height() + self.padding * 2) + self.size = (self.text_object.get_width() + self.padding[0] * 2, self.text_object.get_height() + self.padding[1] * 2) new_callable_pos = None