新增功能
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
os.environ["QT_SCALE_FACTOR"] = "1"
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
sys.argv = [sys.argv[0], "--qt-smoke-test"]
|
||||
|
||||
from PySide6.QtCore import QSize, QTimer
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from wechat_gui_qt import (
|
||||
APP_QSS,
|
||||
WIN_TITLE,
|
||||
MainWindow,
|
||||
_app_icon,
|
||||
_register_bundled_fonts,
|
||||
_ui_font,
|
||||
)
|
||||
|
||||
out = ROOT / "tmp"
|
||||
app = QApplication.instance() or QApplication(sys.argv)
|
||||
_register_bundled_fonts()
|
||||
app.setApplicationName(WIN_TITLE)
|
||||
app.setWindowIcon(_app_icon())
|
||||
app.setStyle("Fusion")
|
||||
app.setStyleSheet(APP_QSS)
|
||||
app.setFont(_ui_font(9))
|
||||
window = MainWindow()
|
||||
window.setFixedSize(QSize(1630, 920))
|
||||
window.show()
|
||||
window.raise_()
|
||||
|
||||
|
||||
def run_captures() -> None:
|
||||
def next_page(index: int) -> None:
|
||||
if index >= window.stack.count():
|
||||
app.quit()
|
||||
return
|
||||
window.show_page(index)
|
||||
QApplication.processEvents()
|
||||
QTimer.singleShot(450, lambda: grab_and_continue(index))
|
||||
|
||||
def grab_and_continue(index: int) -> None:
|
||||
pix = window.grab()
|
||||
path = out / f"qt-ui-smoke-{index + 1}.png"
|
||||
ok = pix.save(str(path))
|
||||
print(index, ok, pix.width(), pix.height(), path, path.exists(), path.stat().st_size if path.exists() else 0)
|
||||
next_page(index + 1)
|
||||
|
||||
next_page(0)
|
||||
|
||||
|
||||
def start_when_ready() -> None:
|
||||
if getattr(window.console_shell, "page_ready", False):
|
||||
QTimer.singleShot(600, run_captures)
|
||||
return
|
||||
QTimer.singleShot(200, start_when_ready)
|
||||
|
||||
|
||||
QTimer.singleShot(400, start_when_ready)
|
||||
QTimer.singleShot(20000, app.quit)
|
||||
raise SystemExit(app.exec())
|
||||
Reference in New Issue
Block a user