From 1207a6243730706c52d6840b27454e8f392ed7fd Mon Sep 17 00:00:00 2001 From: kiyreload27 Date: Wed, 31 Dec 2025 23:35:44 +0000 Subject: [PATCH] feat: Implement main application GUI with tabbed interface, add seed database, and enhance image path resolution. --- database/umamusume_seed.db | Bin 1581056 -> 1581056 bytes gui/main_window.py | 73 +++++++++++++++++++++++++++++++++++++ utils.py | 48 +++++++++++++++++------- version.py | 2 +- 4 files changed, 109 insertions(+), 14 deletions(-) diff --git a/database/umamusume_seed.db b/database/umamusume_seed.db index 473e962ce28891dce6d610118b273570e7594bef..58dd9188b471c4872bb405f7a77ca81f316afb51 100644 GIT binary patch delta 83 zcmV~$NfCoU006-voZ(CeBtl{Y2`gob$4KFg1ROAqpgSHR9$~-E 0: + info.append(f"Sample: {files[0]}") + + content = "\n".join(info) + + # Display area + text_frame = tk.Frame(diag_win, bg=BG_DARK, padx=20, pady=20) + text_frame.pack(fill=tk.BOTH, expand=True) + + from gui.theme import create_styled_text + text_area = create_styled_text(text_frame) + text_area.pack(fill=tk.BOTH, expand=True) + text_area.insert(tk.END, content) + text_area.config(state=tk.DISABLED) + + # Close button + btn_frame = tk.Frame(diag_win, bg=BG_DARK, pady=15) + btn_frame.pack(fill=tk.X) + create_styled_button(btn_frame, text="Close", command=diag_win.destroy).pack() + def run(self): """ Start the GUI application and display the main window. diff --git a/utils.py b/utils.py index f7d2ffa..c4cc61b 100644 --- a/utils.py +++ b/utils.py @@ -6,23 +6,45 @@ def resolve_image_path(db_path): """ Resolve the absolute path to an image file. Handles the case where the database contains paths from a different machine/drive. - Also handles frozen (PyInstaller) state. + Searches multiple locations: + 1. Bundled resources (_MEIPASS for PyInstaller) + 2. Local 'images' folder next to the .exe or project root + 3. The directory containing the source files """ if not db_path: return None filename = os.path.basename(db_path) - # Check if running as frozen executable - if getattr(sys, 'frozen', False): - # PyInstaller creates a temp folder and stores path in _MEIPASS - if hasattr(sys, '_MEIPASS'): - root_dir = sys._MEIPASS - else: - root_dir = os.path.dirname(sys.executable) - else: - # Get the project root directory (directory where this utils.py resides) - root_dir = os.path.dirname(os.path.abspath(__file__)) + # List of directories to search + search_dirs = [] - # Construct optimal path - return os.path.join(root_dir, 'images', filename) + # 1. Check if running as frozen executable + if getattr(sys, 'frozen', False): + if hasattr(sys, '_MEIPASS'): + # Bundled images folder in _MEIPASS + search_dirs.append(os.path.join(sys._MEIPASS, 'images')) + + # Folder next to the .exe + exe_dir = os.path.dirname(sys.executable) + search_dirs.append(os.path.join(exe_dir, 'images')) + search_dirs.append(exe_dir) # Maybe images are flat in exe dir + + # 2. Source code directory + source_dir = os.path.dirname(os.path.abspath(__file__)) + search_dirs.append(os.path.join(source_dir, 'images')) + + # 3. Parent of source code (project root) + project_root = os.path.dirname(source_dir) + search_dirs.append(os.path.join(project_root, 'images')) + + # Try each search directory + for d in search_dirs: + if not d: continue + test_path = os.path.join(d, filename) + if os.path.exists(test_path): + return test_path + + # Fallback: if we haven't found it, return what would be the standard local path + # even if it doesn't exist (helpful for debugging) + return os.path.join(source_dir, 'images', filename) diff --git a/version.py b/version.py index fe59d97..3852d32 100644 --- a/version.py +++ b/version.py @@ -4,7 +4,7 @@ This file is the single source of truth for the application version. """ # Semantic versioning: MAJOR.MINOR.PATCH -VERSION: str = "13.0.2" +VERSION: str = "13.0.3" # Application metadata APP_NAME: str = "UmamusumeCardManager"