56 lines
1.3 KiB
Python
56 lines
1.3 KiB
Python
"""hk4e-GM 复刻版(PySide6 界面)入口。
|
||
|
||
python app2.py
|
||
python app2.py --screenshot out.png [页面key]
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import argparse
|
||
import os
|
||
import sys
|
||
|
||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||
if HERE not in sys.path:
|
||
sys.path.insert(0, HERE)
|
||
|
||
try:
|
||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||
except Exception:
|
||
pass
|
||
|
||
|
||
def main(argv=None) -> int:
|
||
ap = argparse.ArgumentParser(description="hk4e-GM Python 复刻版(PySide6)")
|
||
ap.add_argument("--screenshot", metavar="PNG")
|
||
ap.add_argument("--page", default="item")
|
||
args = ap.parse_args(argv)
|
||
|
||
from PySide6.QtCore import QTimer
|
||
from PySide6.QtWidgets import QApplication
|
||
|
||
from ui2 import theme
|
||
from ui2.main import GMWindow, _dark_titlebar
|
||
|
||
app = QApplication(sys.argv)
|
||
theme.install(app)
|
||
win = GMWindow()
|
||
win.show()
|
||
_dark_titlebar(int(win.winId()))
|
||
|
||
if args.screenshot:
|
||
win.show_page(args.page)
|
||
|
||
def shot():
|
||
app.processEvents()
|
||
pix = win.grab()
|
||
pix.save(args.screenshot)
|
||
print(f"screenshot saved: {args.screenshot} ({pix.width()}x{pix.height()})")
|
||
app.quit()
|
||
|
||
QTimer.singleShot(900, shot)
|
||
return app.exec()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|