diff --git a/README.md b/README.md index d9da849..36021ad 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ pip install pyinstaller ```powershell pyinstaller -F -w ` --icon="app.ico" ` + --add-data "app.ico;." ` --hidden-import "win32com.client" ` --hidden-import "pythoncom" ` --hidden-import "pywintypes" ` diff --git a/src/ui/gui.py b/src/ui/gui.py index e593c14..8966dcb 100644 --- a/src/ui/gui.py +++ b/src/ui/gui.py @@ -19,6 +19,18 @@ class BatchTableExtractorApp: self.root.title("WordTableExtractor") self.root.geometry("640x520") self.root.minsize(580, 460) + + # 尝试设置窗口图标 + try: + import sys + if getattr(sys, 'frozen', False): + icon_path = os.path.join(sys._MEIPASS, "app.ico") + else: + icon_path = os.path.join(APP_DIR, "app.ico") + if os.path.exists(icon_path): + self.root.iconbitmap(icon_path) + except Exception: + pass # 状态变量 self.mode_var = tk.StringVar(value="dir") # "file" 或 "dir"