From: mar77i Date: Thu, 13 Feb 2025 23:40:38 +0000 (+0100) Subject: no need to super().draw() and super().update() on Parent X-Git-Url: https://git.mar77i.info/?a=commitdiff_plain;h=7b258e479546b41a3c92f37dfaf4b4a0007dae2e;p=zenbook_gui no need to super().draw() and super().update() on Parent --- diff --git a/ui/child.py b/ui/child.py index efbec9a..d70296d 100644 --- a/ui/child.py +++ b/ui/child.py @@ -59,3 +59,9 @@ class Child(EventMethodDispatcher): @property def stop_event(self): return self.root.stop_event + + def update(self): + pass + + def draw(self): + pass diff --git a/ui/drop_down.py b/ui/drop_down.py index 92076e8..ac48dee 100644 --- a/ui/drop_down.py +++ b/ui/drop_down.py @@ -35,10 +35,7 @@ class DropDownMenu(Modal): self.deactivate() -class DropDown(Parent, Button): +class DropDown(Button): def __init__(self, parent, rect, value, entries, callback, is_active=False): - super().__init__(parent, rect, value, self.activate, is_active) - self.dropdown_menu = DropDownMenu(self, rect, entries, callback) - - def activate(self): - self.dropdown_menu.activate() + self.dropdown_menu = DropDownMenu(parent, rect, entries, callback) + super().__init__(parent, rect, value, self.dropdown_menu.activate, is_active) diff --git a/ui/event_method_dispatcher.py b/ui/event_method_dispatcher.py index 8e54854..2b03755 100644 --- a/ui/event_method_dispatcher.py +++ b/ui/event_method_dispatcher.py @@ -28,9 +28,3 @@ class EventMethodDispatcher: method_name = f"handle_{pygame.event.event_name(ev.type).lower()}" if hasattr(self, method_name): getattr(self, method_name)(ev) - - def update(self): - pass - - def draw(self): - pass diff --git a/ui/parent.py b/ui/parent.py index bfd87d2..22fed96 100644 --- a/ui/parent.py +++ b/ui/parent.py @@ -20,11 +20,9 @@ class Parent(EventMethodDispatcher): break def update(self): - super().update() for child in self.children: child.update() def draw(self): - super().draw() for child in self.children: child.draw()