Fix exe silent start: show activation window instead of hidden Tk parent.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-17 19:32:35 +08:00
parent d25a4c6862
commit accdab9499
3 changed files with 114 additions and 60 deletions
+22 -7
View File
@@ -1472,14 +1472,10 @@ class OrderApp(tk.Tk):
def main() -> None:
enable_dpi_awareness()
# 先建隐藏根窗完成激活,再开主界面
boot = tk.Tk()
boot.withdraw()
# 激活窗自管可见性(勿对隐藏根窗挂 Toplevel,Windows 上会双击无界面)
if ensure_activated is not None:
if not ensure_activated(boot):
boot.destroy()
if not ensure_activated():
return
boot.destroy()
app = OrderApp()
if is_activated():
@@ -1495,4 +1491,23 @@ def main() -> None:
if __name__ == "__main__":
main()
try:
main()
except Exception as exc:
try:
import traceback
from pathlib import Path
log = Path.home() / ".gold_monitor" / "crash.log"
log.parent.mkdir(parents=True, exist_ok=True)
log.write_text(traceback.format_exc(), encoding="utf-8")
except Exception:
pass
try:
root = tk.Tk()
root.withdraw()
messagebox.showerror("黄金市价辅助", f"启动失败:{exc}\n详情见 %USERPROFILE%\\.gold_monitor\\crash.log")
root.destroy()
except Exception:
pass
raise