Skip to content

Commit a841f1f

Browse files
committed
修复std问题
1 parent 670cdc6 commit a841f1f

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

main.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
# entrypoint.py 顶部
2+
import os
3+
import sys
4+
import atexit
5+
6+
def _ensure_stdio_redirect():
7+
# 在无控制台(--windowed)打包的 exe 下,stdout/stderr 常为 None
8+
base_dir = os.path.dirname(getattr(sys, "executable", "") or os.getcwd())
9+
out_path = os.path.join(base_dir, "stdout.log")
10+
err_path = os.path.join(base_dir, "stderr.log")
11+
12+
def _open(path):
13+
try:
14+
return open(path, "a", buffering=1, encoding="utf-8", errors="backslashreplace")
15+
except Exception:
16+
return open(os.devnull, "w")
17+
18+
if not getattr(sys.stdout, "write", None):
19+
sys.stdout = _open(out_path)
20+
atexit.register(sys.stdout.close)
21+
if not getattr(sys.stderr, "write", None):
22+
sys.stderr = _open(err_path)
23+
atexit.register(sys.stderr.close)
24+
25+
_ensure_stdio_redirect()
26+
27+
28+
29+
30+
131
import tkinter as tk
232
import webbrowser
333
import threading

res.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
Auto-generated file. Do NOT edit manually.
5-
Generated at: 2025-09-11 20:39:53
5+
Generated at: 2025-09-11 20:47:33
66
Source: script/pack_res.py
77
Content: Base64-encoded payloads with MIME types and encoding ('gzip' or 'identity').
88
"""

0 commit comments

Comments
 (0)