-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbead_pattern_tool.py
More file actions
33 lines (29 loc) · 977 Bytes
/
Copy pathbead_pattern_tool.py
File metadata and controls
33 lines (29 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
import sys, os, traceback
sys.dont_write_bytecode = True
_dir = os.path.dirname(os.path.abspath(__file__))
if _dir not in sys.path:
sys.path.insert(0, _dir)
def main():
from bead_pattern_tool.gui import App
App().mainloop()
if __name__ == "__main__":
try:
main()
except Exception:
err = traceback.format_exc()
# 兜底:写入日志文件
log = os.path.join(os.path.dirname(__file__), "_crash.log")
with open(log, "w", encoding="utf-8") as f:
f.write(err)
# 尝试用 tkinter 弹窗显示错误
try:
import tkinter.messagebox
root = __import__('tkinter').Tk()
root.withdraw()
tkinter.messagebox.showerror("程序崩溃", f"发生未捕获异常,已写入 _crash.log\n\n{err[-1500:]}")
root.destroy()
except Exception:
pass
print(err, file=sys.stderr)
sys.exit(1)