66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
"""Render the reception daily-record matrix for visual acceptance."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
|
|
from PySide6.QtCore import QThreadPool
|
|
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:
|
|
application = QApplication.instance() or QApplication([])
|
|
apply_theme(application)
|
|
|
|
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(5):
|
|
application.processEvents()
|
|
QThreadPool.globalInstance().waitForDone(10_000)
|
|
page = window.pages["reception"]
|
|
daily_index = next(
|
|
index
|
|
for index in range(page.detail_tabs.count())
|
|
if page.detail_tabs.tabText(index) == "日常记录"
|
|
)
|
|
page.detail_tabs.setCurrentIndex(daily_index)
|
|
for _index in range(3):
|
|
application.processEvents()
|
|
QThreadPool.globalInstance().waitForDone(10_000)
|
|
|
|
output = (
|
|
Path(__file__).resolve().parents[1]
|
|
/ "artifacts"
|
|
/ "reception_daily_records"
|
|
/ "reception_daily_records_1710x920.png"
|
|
)
|
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
if not window.grab().save(str(output), "PNG"):
|
|
raise RuntimeError(f"failed to save {output}")
|
|
print(output)
|
|
print(
|
|
"DAILY_MATRIX",
|
|
page.daily_panel.matrix.rowCount(),
|
|
page.daily_panel.matrix.columnCount(),
|
|
page.daily_panel.current_range(),
|
|
)
|
|
window.close()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|