Compare commits
No commits in common. "6df677bb849cf191e85996a75479ed01d1718886" and "58506392cbb21ae7396a8af7bbfee065feec5529" have entirely different histories.
6df677bb84
...
58506392cb
1 changed files with 28 additions and 35 deletions
63
pg.py
63
pg.py
|
@ -137,6 +137,28 @@ 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
|
||||||
|
|
||||||
|
@ -150,48 +172,19 @@ 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.background = self.generate_background()
|
self.generate_text(new_text)
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue