Size the window to aproximately 1/3 the screen space

windows_testing_volume
wattygetlood 2021-09-19 18:34:17 -04:00 committed by Tyler Goodlet
parent 02e9240986
commit a5d38df689
1 changed files with 11 additions and 4 deletions

View File

@ -163,6 +163,7 @@ class MainWindow(QtGui.QMainWindow):
self._status_bar: QStatusBar = None self._status_bar: QStatusBar = None
self._status_label: QLabel = None self._status_label: QLabel = None
self._size: Optional[tuple[int, int]] = None
@property @property
def mode_label(self) -> QtGui.QLabel: def mode_label(self) -> QtGui.QLabel:
@ -269,12 +270,18 @@ class MainWindow(QtGui.QMainWindow):
def configure_to_desktop( def configure_to_desktop(
self, self,
size: Optional[tuple[int, int]] = None,
) -> None: ) -> None:
# https://stackoverflow.com/a/18975846 # https://stackoverflow.com/a/18975846
if not size and not self._size:
app = QtGui.QApplication.instance() app = QtGui.QApplication.instance()
geo = self.current_screen().geometry() geo = self.current_screen().geometry()
h, w = geo.height(), geo.width() h, w = geo.height(), geo.width()
self.resize(round(w * .375), round(h * 3/8)) self.setMaximumSize(w, h)
# use approx 1/3 of the area of the screen by default
self._size = round(w * .666), round(h * .666)
self.resize(*size or self._size)