本文整理汇总了Python中PyQt5.QtWidgets.QDesktopWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QDesktopWidget方法的具体用法?Python QtWidgets.QDesktopWidget怎么用?Python QtWidgets.QDesktopWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QDesktopWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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()
示例2: initUI
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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)
示例3: center
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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())
示例4: read_settings
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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]
示例5: center
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
def center(self):
screen = QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) // 2, (screen.height() - size.height()) // 2)
示例6: showEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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)
示例7: generate_display_position
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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)
示例8: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
def __init__(self, parent=None):
super(FixedComboBox, self).__init__(parent)
screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
self.adjusted_size = screen_width // 6
示例9: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
def __init__(self, parent=None):
super(FixedLineEdit, self).__init__(parent)
screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
self.adjusted_size = screen_width // 4.5
示例10: fitImageToScreen
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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)
示例11: centering_window
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
def centering_window(self):
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
示例12: centerOnScreen
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
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),
)
示例13: center
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
def center(self):
qr = self.frameGeometry()
cp = QtWidgets.QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
示例14: center
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
def center(self):
qr = self.frameGeometry()
cp = QtWidgets.QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
示例15: center
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDesktopWidget [as 别名]
def center(self):
screen = QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) // 2, (screen.height() - size.height()) // 2)