fix: 设置窗口标题栏图标并将其打包进可执行文件
This commit is contained in:
@@ -86,6 +86,7 @@ pip install pyinstaller
|
|||||||
```powershell
|
```powershell
|
||||||
pyinstaller -F -w `
|
pyinstaller -F -w `
|
||||||
--icon="app.ico" `
|
--icon="app.ico" `
|
||||||
|
--add-data "app.ico;." `
|
||||||
--hidden-import "win32com.client" `
|
--hidden-import "win32com.client" `
|
||||||
--hidden-import "pythoncom" `
|
--hidden-import "pythoncom" `
|
||||||
--hidden-import "pywintypes" `
|
--hidden-import "pywintypes" `
|
||||||
|
|||||||
@@ -19,6 +19,18 @@ class BatchTableExtractorApp:
|
|||||||
self.root.title("WordTableExtractor")
|
self.root.title("WordTableExtractor")
|
||||||
self.root.geometry("640x520")
|
self.root.geometry("640x520")
|
||||||
self.root.minsize(580, 460)
|
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.mode_var = tk.StringVar(value="dir") # "file" 或 "dir"
|
||||||
|
|||||||
Reference in New Issue
Block a user