fix: 设置窗口标题栏图标并将其打包进可执行文件
This commit is contained in:
@@ -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" `
|
||||
|
||||
@@ -20,6 +20,18 @@ class BatchTableExtractorApp:
|
||||
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"
|
||||
self.src_path_var = tk.StringVar()
|
||||
|
||||
Reference in New Issue
Block a user