Files
kefu/deploy/single-instance-tray-20260917/refine_qt_lifecycle.py
T
2026-09-21 10:34:06 +08:00

13 lines
648 B
Python

from pathlib import Path
import os
for root in (Path('C:/wechat_rpa'), Path('C:/kefu/wechat_rpa')):
path = root / 'wechat_gui_qt.py'
s = path.read_text(encoding='utf-8')
old = ' def closeEvent(self, event) -> None:\n if (not getattr(self, "_exit_requested", False)'
new = ' def closeEvent(self, event) -> None:\n if not hasattr(self, "runtime_settings"):\n event.accept()\n return\n if (not getattr(self, "_exit_requested", False)'
assert old in s
s = s.replace(old, new, 1)
t = path.with_suffix('.tray.tmp')
t.write_text(s, encoding='utf-8')
os.replace(t, path)