feat: adapt DSH assistant to Harness desktop three-column UI
This commit is contained in:
1 parent
2f58f07a5a
commit
9c508333bb
7 files changed
+569
-51
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""Launch or render the actual DSH panel without opening CAD or a task database."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'src'))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--screenshot', type=Path)
|
||||
parser.add_argument('--width', type=int, default=1320)
|
||||
parser.add_argument('--height', type=int, default=820)
|
||||
args = parser.parse_args()
|
||||
if args.screenshot:
|
||||
os.environ['QT_QPA_PLATFORM'] = 'offscreen'
|
||||
from PySide6.QtGui import QFont, QFontDatabase
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from dx_productivity.dsh.client import DshConfig, OpenAICompatibleClient
|
||||
from dx_productivity.trial_task_center.ui.dsh_panel import DshPanel
|
||||
|
||||
app = QApplication([])
|
||||
# Offscreen Qt does not discover the Windows system font collection itself.
|
||||
font_path = Path('C:/Windows/Fonts/msyh.ttc')
|
||||
if args.screenshot and font_path.exists():
|
||||
QFontDatabase.addApplicationFont(str(font_path))
|
||||
app.setFont(QFont('Microsoft YaHei', 10))
|
||||
panel = DshPanel(None, client=OpenAICompatibleClient(DshConfig(
|
||||
base_url=os.getenv('DSH_API_BASE', ''), model=os.getenv('DSH_MODEL', ''),
|
||||
api_key=os.getenv('DSH_API_KEY', ''))))
|
||||
panel.resize(args.width, args.height)
|
||||
panel.show()
|
||||
if args.screenshot:
|
||||
app.processEvents()
|
||||
args.screenshot.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not panel.grab().save(str(args.screenshot)):
|
||||
raise RuntimeError('Could not save screenshot')
|
||||
print(args.screenshot.resolve())
|
||||
panel.close()
|
||||
return 0
|
||||
return app.exec()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user