From 7b258e479546b41a3c92f37dfaf4b4a0007dae2e Mon Sep 17 00:00:00 2001 From: mar77i Date: Fri, 14 Feb 2025 00:40:38 +0100 Subject: [PATCH] no need to super().draw() and super().update() on Parent --- ui/child.py | 6 ++++++ ui/drop_down.py | 9 +++------ ui/event_method_dispatcher.py | 6 ------ ui/parent.py | 2 -- 4 files changed, 9 insertions(+), 14 deletions(-) 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() -- 2.51.0