def build_app_window(): app = QApplication([]) window = QMainWindow() screen_rect = app.primaryScreen().geometry() window.move(screen_rect.left(), screen_rect.top()) window.resize(600, 600) w = QWidget() w.setLayout(QVBoxLayout()) window.setCentralWidget(w) window.app = app return window
def open_appless_panel(panel_cls: Type[Panel]): # pragma: no cover import asyncio app = QApplication([]) font_db = QFontDatabase() for font in (Path(__file__).parent / "resources" / "fonts").glob("*.ttf"): font_db.addApplicationFont(str(font)) app.setStyleSheet(default_stylesheet()) class FauxParent: def client_panel_will_close(self, _): app.exit() class Hooks: qt_app = None def __init__(self, qt_app): self.qt_app = qt_app async def process_events(self): while True: await asyncio.sleep(0.03) self.qt_app.processEvents() window_widget = panel_cls(parent=FauxParent(), id="appless", app=None) window = QMainWindow() window.setCentralWidget(window_widget) screen_rect = app.primaryScreen().geometry() window.move(screen_rect.left(), screen_rect.top()) window.resize(*panel_cls.SIZE) window.app = None window.show() loop = asyncio.get_event_loop() asyncio.ensure_future(Hooks(app).process_events()) loop.run_forever()