diff --git a/pg.py b/pg.py index 907de47..420704c 100644 --- a/pg.py +++ b/pg.py @@ -30,7 +30,7 @@ class Hover: self.x, self.y = position self.w, self.h = size - elif position is Callable: + elif callable(position): self.x, self.y = position() self.callable_position = position @@ -41,6 +41,7 @@ class Hover: mx, my = mouse_pos if not self.ca is None: + print(type(self.ca)) if self.ca.collidepoint((mx, my)): if self.function is None: return True @@ -74,7 +75,7 @@ class Button: self.x, self.y = position self.width, self.height = size - elif position is Callable: + elif callable(position): self.x, self.y = position() self.callable_position = position @@ -83,6 +84,8 @@ class Button: self.ca = ca self.key = key + print(type(ca)) + self.hover = Hover(function, ca, position, size) if buttonlist: @@ -111,7 +114,7 @@ class TextButton: self.padding = padding self.callable_position = None - if position is tuple: + if type(position) is tuple: self.position = position else: @@ -168,7 +171,7 @@ class TextButton: if not new_callable_pos is None: new_pos = new_callable_pos(self.size) - elif new_pos is tuple: + elif type(new_pos) is tuple: new_callable_pos = None else: @@ -189,10 +192,12 @@ class TextButton: self.surface = new_surface self.function = new_func - self.button = Button(new_func, new_bg_color, key=new_key) - self.background = self.generate_background() + self.button = Button(new_func, self.background, key=new_key) + + + def blit(self, surface: pygame.Surface=None): x, y = self.position