From 2ebdf008da2517c602d5e07082034bc87a4c4556 Mon Sep 17 00:00:00 2001 From: wattygetlood <61716739+wattygetlood@users.noreply.github.com> Date: Thu, 16 Sep 2021 16:33:48 -0400 Subject: [PATCH] Configure window size based on screen dims on windows --- piker/ui/_exec.py | 4 ++++ piker/ui/_window.py | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/piker/ui/_exec.py b/piker/ui/_exec.py index 284ddd9b..7b69acef 100644 --- a/piker/ui/_exec.py +++ b/piker/ui/_exec.py @@ -61,7 +61,9 @@ _do_overrides() # XXX: pretty sure none of this shit works on linux as per: # https://bugreports.qt.io/browse/QTBUG-53022 # it seems to work on windows.. no idea wtf is up. +is_windows = False if platform.system() == "Windows": + is_windows = True # Proper high DPI scaling is available in Qt >= 5.6.0. This attibute # must be set before creating the application @@ -182,6 +184,8 @@ def run_qtractor( window.main_widget = main_widget window.setCentralWidget(instance) + if is_windows: + window.configure_to_desktop() # actually render to screen window.show() diff --git a/piker/ui/_window.py b/piker/ui/_window.py index 6a0c1d8b..da9dd305 100644 --- a/piker/ui/_window.py +++ b/piker/ui/_window.py @@ -153,8 +153,8 @@ class MainWindow(QtGui.QMainWindow): # XXX: for tiling wms this should scale # with the alloted window size. # TODO: detect for tiling and if untrue set some size? - # size = (300, 500) - size = (0, 0) + size = (300, 500) + #size = (0, 0) title = 'piker chart (ur symbol is loading bby)' @@ -165,7 +165,7 @@ class MainWindow(QtGui.QMainWindow): self._status_bar: QStatusBar = None self._status_label: QLabel = None - + @property def mode_label(self) -> QtGui.QLabel: @@ -269,6 +269,16 @@ class MainWindow(QtGui.QMainWindow): assert screen, "Wow Qt is dumb as shit and has no screen..." return screen + def configure_to_desktop( + self, + ) -> None: + # https://stackoverflow.com/a/18975846 + app = QtGui.QApplication.instance() + geo = self.current_screen().geometry() + h, w = geo.height(), geo.width() + self.resize(round(w * .375), round(h * 3/8)) + + # singleton app per actor _qt_win: QtGui.QMainWindow = None