Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions taskon/resources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
from tkinter import PhotoImage


Expand All @@ -16,12 +17,16 @@ def __init__(self, base_path=None):

Args:
base_path: Directory path to load images from. If None, defaults
to '../assets/images/' relative to this file.
to 'assets/images' inside PyInstaller temp or source folder.
"""
if base_path is None:
# Absolute path relative to this file
base_path = os.path.join(os.path.dirname(__file__), "assets/images")
self.base_path = os.path.abspath(base_path) # converts to absolute path
if hasattr(sys, '_MEIPASS'):
# Running inside PyInstaller bundle
base_path = os.path.join(sys._MEIPASS, 'assets', 'images')
else:
# Running from source
base_path = os.path.join(os.path.dirname(__file__), 'assets', 'images')
self.base_path = os.path.abspath(base_path)

# --------------------------
# Resource Loading Methods
Expand Down
Loading