Skip to content

Commit

Permalink
BUG: use primary screen to center main window
Browse files Browse the repository at this point in the history
The existing code to resize and recenter the main window
had a bug where multiple monitors were apparently being
reported as one large screen, causing the window to appear
in between two monitors.  This commit centers the window
on the primary screen specifically.
  • Loading branch information
shilorigins committed Oct 28, 2024
1 parent f871071 commit e943055
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 9 additions & 0 deletions superscore/bin/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from superscore.client import Client
from superscore.widgets.window import Window

DEFAULT_WIDTH = 1400
DEFAULT_HEIGHT = 800


def build_arg_parser(argparser=None):
if argparser is None:
Expand All @@ -22,5 +25,11 @@ def main(*args, client: Optional[Client] = None, **kwargs):
app = QApplication(sys.argv)
main_window = Window(client=client)

primary_screen = app.screens()[0]
center = primary_screen.geometry().center()
# move window rather creating a QRect because we want to include the frame geometry
main_window.setGeometry(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT)
delta = main_window.geometry().center()
main_window.move(center - delta)
main_window.show()
app.exec()
5 changes: 0 additions & 5 deletions superscore/widgets/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

logger = logging.getLogger(__name__)

DEFAULT_WIDTH = 1400
DEFAULT_HEIGHT = 800


class Window(Display, QtWidgets.QMainWindow):
"""Main superscore window"""
Expand All @@ -47,8 +44,6 @@ def __init__(self, *args, client: Optional[Client] = None, **kwargs):

self._partial_slots = []

self.resize(DEFAULT_WIDTH, DEFAULT_HEIGHT)
self.move(self.screen().geometry().center() - self.frameGeometry().center())
self.setup_ui()
self.open_search_page()

Expand Down

0 comments on commit e943055

Please sign in to comment.