Python PyQt5.QtWidgets.QDesktopWidget() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QDesktopWidget(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: Games   Author: CharlesPikachu   File: Game11.py    License: MIT License 6 votes vote down vote up
def center(self):
		screen = QDesktopWidget().screenGeometry()
		size = self.geometry()
		self.move((screen.width() - size.width()) // 2, (screen.height() - size.height()) // 2) 
Example 2
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    License: GNU General Public License v3.0 6 votes vote down vote up
def showEvent(self, event=None):
        viewport_topRight = self.contentView.mapToGlobal(
            self.contentView.viewport().rect().topRight())

        desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
        dock_y = viewport_topRight.y()
        dock_height = self.contentView.viewport().size().height()

        if self.notes_only:
            dock_width = dock_height = desktop_size.width() // 5.5
            dock_x = QtGui.QCursor.pos().x()
            dock_y = QtGui.QCursor.pos().y()
        else:
            dock_width = desktop_size.width() // 5
            dock_x = viewport_topRight.x() - dock_width + 1
            self.parent.navBar.hide()

        self.main_window.active_docks.append(self)
        self.setGeometry(dock_x, dock_y, dock_width, dock_height)
        self.animation.start() 
Example 3
Project: qiew   Author: mtivadar   File: qiew.py    License: GNU General Public License v2.0 6 votes vote down vote up
def initUI(self):      

        self.wid = binWidget(self, self._source)
        
        self.hbox = QtWidgets.QHBoxLayout()
        self.hbox.addWidget(self.wid)
        self.setLayout(self.hbox)

        screen = QtWidgets.QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, screen.width()-100, screen.height()-100)

        self.setWindowTitle(self._title)
        #self.showMaximized()
        self.wid.activateWindow()

        self.raise_()
        self.installEventFilter(self) 
Example 4
Project: equant   Author: epolestar   File: framelesswindow.py    License: GNU General Public License v2.0 6 votes vote down vote up
def center(self, pGeometry=None):
        if pGeometry:
            pr = pGeometry
            x, y, w, h = pr.x(), pr.y(), pr.width(), pr.height()
            # 父窗口的中心点坐标
            cenPosX = x + w / 2
            cenPosY = y + h / 2
            size = self.size()
            xPos = cenPosX - size.width() / 2
            yPos = cenPosY - size.height() / 2
            self.move(xPos, yPos)
        else:
            qr = self.frameGeometry()
            cp = QDesktopWidget().availableGeometry().center()
            qr.moveCenter(cp)
            self.move(qr.topLeft()) 
Example 5
Project: ANGRYsearch   Author: DoTheEvo   File: angrysearch.py    License: GNU General Public License v2.0 5 votes vote down vote up
def read_settings(self):
        if self.settings.value('Last_Run/geometry'):
            self.restoreGeometry(self.settings.value('Last_Run/geometry'))
        else:
            self.resize(720, 540)
            qr = self.frameGeometry()
            cp = Qw.QDesktopWidget().availableGeometry().center()
            qr.moveCenter(cp)
            self.move(qr.topLeft())

        if self.settings.value('Last_Run/window_state'):
            self.restoreState(self.settings.value('Last_Run/window_state'))

        self.read_qsettings_item('angrysearch_lite', 'bool')
        self.read_qsettings_item('fast_search_but_no_substring', 'bool')
        self.read_qsettings_item('typing_delay', 'bool')
        self.read_qsettings_item('darktheme', 'bool')
        self.read_qsettings_item('fm_path_doubleclick_selects', 'bool')
        self.read_qsettings_item('icon_theme', 'str')
        self.read_qsettings_item('row_height', 'int')
        self.read_qsettings_item('number_of_results', 'int')
        self.read_qsettings_item('directories_excluded', 'list')
        self.read_qsettings_item('file_manager', 'fm')
        self.read_qsettings_item('conditional_mounts_for_autoupdate', 'list')
        self.read_qsettings_item('notifications', 'bool')
        self.read_qsettings_item('regex_mode', 'bool')
        self.read_qsettings_item('close_on_execute', 'bool')

        if self.settings.value('Last_Run/last_sort'):
            k = self.settings.value('Last_Run/last_sort')
            if isinstance(k, list) and len(k) == 2:
                if self.setting_params['angrysearch_lite'] and int(k[0]) > 1:
                    k[0] = 1
                self.setting_params['last_sort'] = [int(x) for x in k]
            else:
                self.setting_params['last_sort'] = [1, 0]
        else:
            self.setting_params['last_sort'] = [1, 0] 
Example 6
Project: Lector   Author: BasioMeusPuga   File: definitionsdialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def showEvent(self, event):
        self.color_background(True)

        size = self.size()
        desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
        top = (desktop_size.height() / 2) - (size.height() / 2)
        left = (desktop_size.width() / 2) - (size.width() / 2)
        self.move(left, top) 
Example 7
Project: Lector   Author: BasioMeusPuga   File: metadatadialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def generate_display_position(self, mouse_cursor_position):
        size = self.size()
        desktop_size = QtWidgets.QDesktopWidget().screenGeometry()

        display_x = mouse_cursor_position.x()
        display_y = mouse_cursor_position.y()

        if display_x + size.width() > desktop_size.width():
            display_x = desktop_size.width() - size.width()

        if display_y + size.height() > desktop_size.height():
            display_y = desktop_size.height() - size.height()

        return QtCore.QPoint(display_x, display_y) 
Example 8
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def showEvent(self, event=None):
        # TODO
        # See what happens when the size of the viewport is smaller
        # than the size of the dock

        viewport_bottomRight = self.contentView.mapToGlobal(
            self.contentView.viewport().rect().bottomRight())

        # Dock dimensions
        desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
        dock_width = desktop_size.width() // 4.5
        dock_height = 30

        dock_x = viewport_bottomRight.x() - dock_width - 30
        dock_y = viewport_bottomRight.y() - 70

        self.main_window.active_docks.append(self)
        self.setGeometry(dock_x, dock_y, dock_width, dock_height)

        # Rounded
        radius = 20
        path = QtGui.QPainterPath()
        path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
        try:
            mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
            self.setMask(mask)
        except TypeError:  # Required for older versions of Qt
            pass

        self.animation.start() 
Example 9
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(FixedComboBox, self).__init__(parent)
        screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
        self.adjusted_size = screen_width // 6 
Example 10
Project: Lector   Author: BasioMeusPuga   File: toolbars.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(FixedLineEdit, self).__init__(parent)
        screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
        self.adjusted_size = screen_width // 4.5 
Example 11
Project: detection   Author: xsyann   File: common.py    License: GNU General Public License v2.0 5 votes vote down vote up
def fitImageToScreen(pixmap):
    """Fit pixmap to screen.
    """
    resolution = QDesktopWidget().screenGeometry()
    h, w = resolution.width(), resolution.height()
    w = min(pixmap.width(), w)
    h = min(pixmap.height(), h)
    return pixmap.scaled(QtCore.QSize(w, h), QtCore.Qt.KeepAspectRatio) 
Example 12
Project: ocelot   Author: ocelot-collab   File: gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def centering_window(self):

        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example 13
Project: pyleecan   Author: Eomys   File: SidebarWindow.py    License: Apache License 2.0 5 votes vote down vote up
def centerOnScreen(self):
        """centerOnScreen() - Centers the window on the screen."""
        resolution = QtWidgets.QDesktopWidget().screenGeometry()
        frame = self.frameSize()
        self.move(
            (resolution.width() / 2) - (frame.width() / 2),
            (resolution.height() / 2) - (frame.height() / 2),
        ) 
Example 14
Project: pyMeteo   Author: cwebster2   File: acars.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def center(self):
        qr = self.frameGeometry()
        cp = QtWidgets.QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example 15
Project: pyMeteo   Author: cwebster2   File: MainInterface.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def center(self):
      qr = self.frameGeometry()
      cp = QtWidgets.QDesktopWidget().availableGeometry().center()
      qr.moveCenter(cp)
      self.move(qr.topLeft()) 
Example 16
Project: tetris_game   Author: LoveDaisy   File: tetris_game.py    License: MIT License 5 votes vote down vote up
def center(self):
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) // 2, (screen.height() - size.height()) // 2) 
Example 17
Project: sparrow-wifi   Author: ghostop14   File: sparrow-wifi.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        # Get our geometry
        qr = self.frameGeometry()
        # Find the desktop center point
        cp = QDesktopWidget().availableGeometry().center()
        # Move our center point to the desktop center point
        qr.moveCenter(cp)
        # Move the top-left point of the application window to the top-left point of the qr rectangle, 
        # basically centering the window
        self.move(qr.topLeft()) 
Example 18
Project: sparrow-wifi   Author: ghostop14   File: sparrowdialogs.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        # Get our geometry
        qr = self.frameGeometry()
        # Find the desktop center point
        cp = QDesktopWidget().availableGeometry().center()
        # Move our center point to the desktop center point
        qr.moveCenter(cp)
        # Move the top-left point of the application window to the top-left point of the qr rectangle, 
        # basically centering the window
        self.move(qr.topLeft()) 
Example 19
Project: sparrow-wifi   Author: ghostop14   File: sparrowdialogs.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        # Get our geometry
        qr = self.frameGeometry()
        # Find the desktop center point
        cp = QDesktopWidget().availableGeometry().center()
        # Move our center point to the desktop center point
        qr.moveCenter(cp)
        # Move the top-left point of the application window to the top-left point of the qr rectangle, 
        # basically centering the window
        self.move(qr.topLeft()) 
Example 20
Project: sparrow-wifi   Author: ghostop14   File: sparrowdialogs.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        # Get our geometry
        qr = self.frameGeometry()
        # Find the desktop center point
        cp = QDesktopWidget().availableGeometry().center()
        # Move our center point to the desktop center point
        qr.moveCenter(cp)
        # Move the top-left point of the application window to the top-left point of the qr rectangle, 
        # basically centering the window
        self.move(qr.topLeft()) 
Example 21
Project: sparrow-wifi   Author: ghostop14   File: sparrowdialogs.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        # Get our geometry
        qr = self.frameGeometry()
        # Find the desktop center point
        cp = QDesktopWidget().availableGeometry().center()
        # Move our center point to the desktop center point
        qr.moveCenter(cp)
        # Move the top-left point of the application window to the top-left point of the qr rectangle, 
        # basically centering the window
        self.move(qr.topLeft()) 
Example 22
Project: sparrow-wifi   Author: ghostop14   File: sparrowdialogs.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        # Get our geometry
        qr = self.frameGeometry()
        # Find the desktop center point
        cp = QDesktopWidget().availableGeometry().center()
        # Move our center point to the desktop center point
        qr.moveCenter(cp)
        # Move the top-left point of the application window to the top-left point of the qr rectangle, 
        # basically centering the window
        self.move(qr.topLeft()) 
Example 23
Project: sparrow-wifi   Author: ghostop14   File: telemetry.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        # Get our geometry
        qr = self.frameGeometry()
        # Find the desktop center point
        cp = QDesktopWidget().availableGeometry().center()
        # Move our center point to the desktop center point
        qr.moveCenter(cp)
        # Move the top-left point of the application window to the top-left point of the qr rectangle, 
        # basically centering the window
        self.move(qr.topLeft()) 
Example 24
Project: eddy   Author: danielepantaleone   File: notification.py    License: GNU General Public License v3.0 5 votes vote down vote up
def setNotificationPos(self):
        """
        Set the position of the notification popup on the curret screen.
        """
        alignedRect = QtWidgets.QStyle.alignedRect(
            QtCore.Qt.LeftToRight,
            QtCore.Qt.AlignRight | QtCore.Qt.AlignTop,
            self.size(),
            QtWidgets.QDesktopWidget().availableGeometry(self.session))
        # MOVE TO CORRECT LOCATION
        alignedRect.translate(-10, (self.num * (self.height() + 10)) + 40)
        # SET THE NOTIFICATION GEOMETRY
        self.setGeometry(alignedRect) 
Example 25
Project: lanzou-gui   Author: rachpt   File: ui.py    License: MIT License 5 votes vote down vote up
def set_window_at_center(self):
        screen = QtWidgets.QDesktopWidget().screenGeometry()
        size = self.geometry()
        new_left = int((screen.width() - size.width()) / 2)
        new_top = int((screen.height() - size.height()) / 2)
        self.move(new_left, new_top) 
Example 26
Project: python   Author: Yeah-Kun   File: Centering_window_on_the_screen.py    License: Apache License 2.0 5 votes vote down vote up
def center(self):

        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example 27
Project: vip_video   Author: nanxung   File: main.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        screen = QtWidgets.QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) 
Example 28
Project: pbtk   Author: marin-m   File: gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def set_view(self, view):
        if hasattr(self, 'view'):
            self.view.hide()
        view.show()
        self.view = view
        
        resolution = QDesktopWidget().screenGeometry()
        view.move((resolution.width() / 2) - (view.frameSize().width() / 2),
                  (resolution.height() / 2) - (view.frameSize().height() / 2)) 
Example 29
Project: Dwarf   Author: iGio90   File: panel_debug.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, app, flags=None):
        super(QDebugPanel, self).__init__(flags)
        self.setDockOptions(QMainWindow.AnimatedDocks | QMainWindow.AllowNestedDocks | QMainWindow.AllowTabbedDocks)

        self.app = app
        self.q_settings = app.q_settings

        screen_size = QtWidgets.QDesktopWidget().screenGeometry(-1)
        m_width = screen_size.width()

        self.memory_panel = HexEditor(self.app)
        self.memory_panel.debug_panel = self
        self.memory_panel.dataChanged.connect(self.on_memory_modified)

        self.disassembly_panel = DisassemblyView(self.app)
        self.disassembly_panel.debug_panel = self

        self.dock_memory_panel = QDockWidget('Memory', self)
        self.dock_memory_panel.setWidget(self.memory_panel)
        self.dock_memory_panel.setObjectName('memory')

        self.dock_disassembly_panel = QDockWidget('Disassembly', self)
        self.dock_disassembly_panel.setWidget(self.disassembly_panel)
        self.dock_disassembly_panel.setObjectName('disassembly')

        self.addDockWidget(Qt.LeftDockWidgetArea, self.dock_memory_panel, Qt.Horizontal)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dock_disassembly_panel, Qt.Horizontal)
        if m_width >= 1920:
            self.splitDockWidget(self.dock_memory_panel, self.dock_disassembly_panel, Qt.Horizontal)
        else:
            self.tabifyDockWidget(self.dock_memory_panel, self.dock_disassembly_panel)

        self.restoreUiState() 
Example 30
Project: legion   Author: GoVanguard   File: configDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        frameGm = self.frameGeometry()
        centerPoint = QtWidgets.QDesktopWidget().availableGeometry().center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())