Compare commits

...

2 commits

63
pg.py
View file

@ -137,28 +137,6 @@ class TextButton:
if new_text is None: if new_text is None:
new_text = self.text new_text = self.text
new_callable_pos = None
if new_pos is None:
new_pos = self.position
new_callable_pos = self.callable_position
elif new_pos is int:
new_callable_pos = None
elif new_pos is Callable:
new_pos = new_pos()
new_callable_pos = new_pos
if new_surface is None:
new_surface = self.surface
if new_func is None:
new_func = self.function
if new_key is None:
new_key = self.button.key
if new_text_color is None: if new_text_color is None:
new_text_color = self.text_color new_text_color = self.text_color
@ -172,19 +150,48 @@ class TextButton:
new_padding = self.padding new_padding = self.padding
self.text = new_text self.text = new_text
self.position = new_pos
self.callable_position = new_callable_pos
self.surface = new_surface
self.function = new_func
self.text_color = new_text_color self.text_color = new_text_color
self.bg_color = new_bg_color self.bg_color = new_bg_color
self.font = new_font self.font = new_font
self.padding = new_padding self.padding = new_padding
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)
new_callable_pos = None
if new_pos is None:
new_pos = self.position
new_callable_pos = self.callable_position
if not new_callable_pos is None:
new_pos = new_callable_pos(self.size)
elif new_pos is int:
new_callable_pos = None
elif new_pos is Callable:
new_pos = new_pos(self.size)
new_callable_pos = new_pos
if new_surface is None:
new_surface = self.surface
if new_func is None:
new_func = self.function
if new_key is None:
new_key = self.button.key
self.position = new_pos
self.callable_position = new_callable_pos
self.surface = new_surface
self.function = new_func
self.button = Button(new_func, new_bg_color, key=new_key) self.button = Button(new_func, new_bg_color, key=new_key)
self.generate_text(new_text) self.background = self.generate_background()
self.generate_background()
def blit(self, surface: pygame.Surface=None): def blit(self, surface: pygame.Surface=None):
x, y = self.position x, y = self.position