From 2545523821891b67166fdc2b3459485a58da6c7b Mon Sep 17 00:00:00 2001 From: Kumuditha Silva Date: Fri, 5 Sep 2025 04:05:01 +0530 Subject: [PATCH] add resource path --- taskon/main.py | 6 ++++-- taskon/resources.py | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/taskon/main.py b/taskon/main.py index 43212e9..1d38803 100644 --- a/taskon/main.py +++ b/taskon/main.py @@ -23,10 +23,12 @@ def main(): root.geometry("250x350") root.config(padx=5, pady=5, bg="#fdfdfd") root.resizable(False, False) - root.iconbitmap("assets/images/growing-seed.ico") - # Load all necessary image resources loader = ResourceLoader() + + icon_path = loader.get_resource_path("growing-seed.ico") + root.iconbitmap(icon_path) + images = { "moon": loader.load_image("clock-green.png"), "oak": loader.load_image("growing-seed.png"), diff --git a/taskon/resources.py b/taskon/resources.py index 54e7374..906bb77 100644 --- a/taskon/resources.py +++ b/taskon/resources.py @@ -39,3 +39,15 @@ def load_image(self, filename: str): """ path = os.path.join(self.base_path, filename) return PhotoImage(file=path) if os.path.exists(path) else None + + def get_resource_path(self, filename: str) -> str: + """ + Get the absolute file path for a resource file. + + Args: + filename: Name of the resource file. + + Returns: + Absolute path to the resource file. + """ + return os.path.join(self.base_path, filename) \ No newline at end of file