first commit
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
"""Render the 1710×920 reception AI acceptance artifact offscreen."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
from PySide6.QtCore import QPoint, QThreadPool
|
||||
from PySide6.QtGui import QFontDatabase
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from doctor_workstation.services.mock_repository import DemoDoctorRepository
|
||||
from doctor_workstation.ui.shell import ShellWindow
|
||||
from doctor_workstation.ui.theme import apply_theme
|
||||
|
||||
|
||||
def main() -> int:
|
||||
app = QApplication.instance() or QApplication([])
|
||||
apply_theme(app)
|
||||
font_path = Path(r"C:\Windows\Fonts\msyh.ttc")
|
||||
if font_path.is_file():
|
||||
QFontDatabase.addApplicationFont(str(font_path))
|
||||
|
||||
repository = DemoDoctorRepository()
|
||||
session = repository.login("doctor", "doctor123")
|
||||
window = ShellWindow(repository, session)
|
||||
window.resize(1710, 920)
|
||||
window.show()
|
||||
if not window.navigate("reception"):
|
||||
raise RuntimeError("reception navigation is unavailable")
|
||||
|
||||
for _index in range(4):
|
||||
app.processEvents()
|
||||
QThreadPool.globalInstance().waitForDone(10_000)
|
||||
app.processEvents()
|
||||
|
||||
output = Path(__file__).resolve().parents[1] / "artifacts" / "reception_ai_exact" / "reception.png"
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
pixmap = window.grab()
|
||||
if pixmap.size().width() != 1710 or pixmap.size().height() != 920:
|
||||
raise RuntimeError(f"unexpected render size: {pixmap.size().width()}x{pixmap.size().height()}")
|
||||
if not pixmap.save(str(output), "PNG"):
|
||||
raise RuntimeError(f"failed to save {output}")
|
||||
|
||||
page = window.pages.get("reception")
|
||||
if page is not None:
|
||||
left = page.ai_analysis_card.geometry()
|
||||
right = page.ai_assistant_card.geometry()
|
||||
left_global = page.ai_analysis_card.mapTo(window, QPoint(0, 0))
|
||||
right_global = page.ai_assistant_card.mapTo(window, QPoint(0, 0))
|
||||
print(
|
||||
"AI_CARDS",
|
||||
left.x(),
|
||||
left.y(),
|
||||
left.width(),
|
||||
left.height(),
|
||||
right.x(),
|
||||
right.y(),
|
||||
right.width(),
|
||||
right.height(),
|
||||
page._ai_analysis_state,
|
||||
)
|
||||
print(
|
||||
"AI_CARDS_GLOBAL",
|
||||
left_global.x(),
|
||||
left_global.y(),
|
||||
right_global.x(),
|
||||
right_global.y(),
|
||||
)
|
||||
print(output)
|
||||
window.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user