Python PyQt5.QtWidgets.QDesktopWidget() Examples

The following are 30 code examples of PyQt5.QtWidgets.QDesktopWidget(). 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 also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: qiew.py    From qiew with 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 #2
Source File: framelesswindow.py    From equant with 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 #3
Source File: image_viewer.py    From pandasgui with MIT License 5 votes vote down vote up
def __init__(self, figs=[]):

        super().__init__()

        self.setWindowTitle("Tabbed Image Viewer")
        self.figs = figs
        layout = QtWidgets.QVBoxLayout()
        self.setLayout(layout)

        # Create tab widget
        self.tab_widget = QtWidgets.QTabWidget()
        self.tab_widget.setMovable(True)
        self.tab_widget.setTabsClosable(True)

        # Add figures to tab widget
        for fig in figs:
            self.add_tab(fig)

        # Just some button connected to `plot` method
        self.button = QtWidgets.QPushButton('To PowerPoint')
        self.button.clicked.connect(self.to_powerpoint)

        # Add widgets to layout
        layout.addWidget(self.tab_widget)
        layout.addWidget(self.button)

        self.show()

        # Center window on screen
        screen = QtWidgets.QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move(int((screen.width() - size.width()) / 2), int((screen.height() - size.height()) / 2)) 
Example #4
Source File: angrysearch.py    From ANGRYsearch with 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 #5
Source File: Centering_window_on_the_screen.py    From python with 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 #6
Source File: main.py    From vip_video with 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 #7
Source File: gui.py    From pbtk with 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 #8
Source File: panel_debug.py    From Dwarf with 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 #9
Source File: configDialog.py    From legion with 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()) 
Example #10
Source File: helpDialog.py    From legion with 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()) 
Example #11
Source File: helpDialog.py    From legion with 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()) 
Example #12
Source File: Tetris.py    From AIGames with 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 #13
Source File: app.py    From strike-with-a-pose with GNU General Public License v3.0 5 votes vote down vote up
def run_gui():
    app = QtWidgets.QApplication([])
    widget = Window("Strike (With) A Pose")
    Scene.wnd = widget.scene_window.wnd
    widget.scene_window.scene_class = Scene
    widget.show()
    widget.move(QtWidgets.QDesktopWidget().rect().center() - widget.rect().center())
    app.exec_()
    del app 
Example #14
Source File: ui.py    From lanzou-gui with 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 #15
Source File: testing1.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        '''
        Figures out the screen resolution of our monitor and centeres the window
        '''
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example #16
Source File: welcome.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        '''
        Figures out the screen resolution of our monitor and centeres the window
        '''
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example #17
Source File: testing.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        '''
        Figures out the screen resolution of our monitor and centeres the window
        '''
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example #18
Source File: testing2.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        '''
        Figures out the screen resolution of our monitor and centeres the window
        '''
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example #19
Source File: setup.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def center(self):
        '''
        Figures out the screen resolution of our monitor and centeres the window
        '''
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example #20
Source File: forward_keyboard.py    From MaixPy_scripts with MIT License 5 votes vote down vote up
def MoveToCenter(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft()) 
Example #21
Source File: egg.py    From PyRAT with Mozilla Public License 2.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 #22
Source File: gui.py    From Yin-Yang with MIT License 5 votes vote down vote up
def center(self):
        frame_gm = self.frameGeometry()
        center_point = QtWidgets.QDesktopWidget().availableGeometry().center()
        frame_gm.moveCenter(center_point)
        self.move(frame_gm.topLeft()) 
Example #23
Source File: gui.py    From Yin-Yang with MIT License 5 votes vote down vote up
def center(self):
        frame_gm = self.frameGeometry()
        center_point = QtWidgets.QDesktopWidget().availableGeometry().center()
        frame_gm.moveCenter(center_point)
        self.move(frame_gm.topLeft()) 
Example #24
Source File: main.py    From controleEstoque with MIT License 5 votes vote down vote up
def centralizar(self):
        # geometry of the main window
        qr = self.frameGeometry()
        # center point of screen
        cp = QtWidgets.QDesktopWidget().availableGeometry().center()
        # move rectangle's center point to screen's center point
        qr.moveCenter(cp)
        # top left of rectangle becomes top left of window centering it
        self.move(qr.topLeft())

    # Verificando Banco de Dados 
Example #25
Source File: SidebarWindow.py    From pyleecan with 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 #26
Source File: Game11.py    From Games with 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 #27
Source File: definitionsdialog.py    From Lector with 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 #28
Source File: metadatadialog.py    From Lector with 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 #29
Source File: dockwidgets.py    From Lector with GNU General Public License v3.0 5 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 #30
Source File: dockwidgets.py    From Lector with 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()