本文整理汇总了Python中PyQt4.QtGui.QDesktopWidget类的典型用法代码示例。如果您正苦于以下问题:Python QDesktopWidget类的具体用法?Python QDesktopWidget怎么用?Python QDesktopWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDesktopWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, title='Popup', message='', params={}, parent=None):
QtGui.QWidget.__init__(self, parent)
width = 300
height = 200
resolution = QDesktopWidget().screenGeometry()
self.setGeometry(resolution.width() - width, resolution.height() - height, width, height)
pos_x = resolution.width() / 2 - width / 2
pos_y = resolution.height() / 2 - height / 2
self.move(pos_x, pos_y)
self.setWindowTitle(title)
self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
self.setToolTip(title)
self.setObjectName("toolTipWindow")
self.setStyleSheet(Resources.read(join('assets', 'styles', 'tooltip.pss')))
self.CComamnd = QtGui.QLabel(message)
#self.CComamnd.setFixedHeight(50)
self.CComamnd.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)
self.CComamnd.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
self.CComamnd.setObjectName('command')
layout = QtGui.QVBoxLayout()
layout.addWidget(self.CComamnd)
self.setLayout(layout)
QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
self.show()
示例2: moveScreenCenter
def moveScreenCenter(self):
w = self.frameGeometry().width()
h = self.frameGeometry().height()
desktop = QDesktopWidget()
screenW = desktop.screen().width()
screenH = desktop.screen().height()
self.setGeometry((screenW-w)/2, (screenH-h)/2, w, h)
示例3: __init__
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.setWindowFlags(Qt.Window)
self._mdi_area = QMdiArea()
self._mdi_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self._mdi_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.setCentralWidget(self._mdi_area)
# set the size of mid_area and DocumentViewManager based on the
# screen size.
screen = QDesktopWidget().availableGeometry()
self._mdi_area.resize(screen.width() - 30, screen.height() - 80)
self.resize(self._mdi_area.size())
self._mdi_area.subWindowActivated.connect(self.update_actions)
self._viewer_mapper = QSignalMapper(self)
self._viewer_mapper.mapped[QWidget].connect(self.set_active_sub_window)
win_title = QApplication.translate(
"DocumentViewManager",
"Document Viewer"
)
self.setWindowTitle(win_title)
self.setUnifiedTitleAndToolBarOnMac(True)
self.statusBar().showMessage(
QApplication.translate(
"DocumentViewManager",
"Ready"
)
)
self._doc_viewers = {}
self._create_menu_actions()
self.update_actions()
示例4: __init__
def __init__(self, new_version = 0, update_link = None):
super(MainForm, self).__init__()
uic.loadUi('UI/LeechMain.ui', self)
dw = QDesktopWidget()
x = dw.width() * 0.7
y = dw.height() * 0.7
self.session = requests.session()
self.btn_start.clicked.connect(self.start_leech)
self.btn_start.setIcon(QtGui.QIcon('UI/start.png'))
self.btn_start.setIconSize(QtCore.QSize(24, 24))
# self.download_table.cellClicked.connect(self.show_download_folder)
self.download_index = 0
self.upload_index = 0
self.download_table.setSelectionBehavior(Qt.QAbstractItemView.SelectRows)
self.upload_table.setSelectionBehavior(Qt.QAbstractItemView.SelectRows)
self.btn_stop.clicked.connect(self.stop_leech)
self.btn_stop.setIcon(QtGui.QIcon('UI/delete.png'))
self.btn_stop.setIconSize(QtCore.QSize(24, 24))
self.setFixedSize(x, y)
self.current_folder = os.getcwd()
self.btn_new_version.clicked.connect(self.normal_update)
self.new_version = new_version
self.update_link = update_link
if float(self.new_version) == 0:
self.btn_new_version.setText("Program is up to date")
else:
self.update_link = update_link
self.btn_new_version.setText("Update to version " + str(new_version))
示例5: __init__
def __init__(self):
""" The Settings constructor initializes the default settings
values, which is provided as a fallback, should the config file
somehow go missing. We use the ``qApp`` instance of The running
``QApplication`` to register organization and application name,
as well as the application version.
"""
QSettings.__init__(self)
# This is the path prefix where we store all luma related
# files (serverlist, templates, filter bookmarks etc.)
self.__configPrefix = ''
# Defaults for section: mainwindow
self.__maximize = False
self.__size = QSize(750, 500)
screen = QDesktopWidget().screenGeometry()
self.__position = QPoint((screen.width() - self.__size.width()) / 2,
(screen.height() - self.__size.height()) / 2)
# Defaults for section: i18n
self.__language = u'en'
# Defaults for section: logger
self.__showLoggerOnStart = False
self.__showLogger = False
self.__showErrors = True
self.__showDebug = True
self.__showInfo = True
示例6: __init__
def __init__(self, alg):
super(AlgorithmDialogBase, self).__init__(iface.mainWindow())
self.setupUi(self)
self.settings = QSettings()
self.restoreGeometry(self.settings.value("/Processing/dialogBase", QByteArray()))
self.executed = False
self.mainWidget = None
self.alg = alg
# Rename OK button to Run
self.btnRun = self.buttonBox.button(QDialogButtonBox.Ok)
self.btnRun.setText(self.tr('Run'))
self.btnClose = self.buttonBox.button(QDialogButtonBox.Close)
self.setWindowTitle(AlgorithmClassification.getDisplayName(self.alg))
desktop = QDesktopWidget()
if desktop.physicalDpiX() > 96:
self.textHelp.setZoomFactor(desktop.physicalDpiX() / 96)
algHelp = self.alg.shortHelp()
if algHelp is None:
self.textShortHelp.setVisible(False)
else:
self.textShortHelp.document().setDefaultStyleSheet('''.summary { margin-left: 10px; margin-right: 10px; }
h2 { color: #555555; padding-bottom: 15px; }
a { text-decoration: none; color: #3498db; font-weight: bold; }
p { color: #666666; }
b { color: #333333; }
dl dd { margin-bottom: 5px; }''')
self.textShortHelp.setHtml(algHelp)
self.textShortHelp.setOpenLinks(False)
def linkClicked(url):
webbrowser.open(url.toString())
self.textShortHelp.anchorClicked.connect(linkClicked)
self.textHelp.page().setNetworkAccessManager(QgsNetworkAccessManager.instance())
isText, algHelp = self.alg.help()
if algHelp is not None:
algHelp = algHelp if isText else QUrl(algHelp)
try:
if isText:
self.textHelp.setHtml(algHelp)
else:
self.textHelp.settings().clearMemoryCaches()
self.textHelp.load(algHelp)
except:
self.tabWidget.removeTab(2)
else:
self.tabWidget.removeTab(2)
self.showDebug = ProcessingConfig.getSetting(
ProcessingConfig.SHOW_DEBUG_IN_DIALOG)
示例7: _center_on_screen
def _center_on_screen(self):
assert isinstance(self, QWidget)
desktop = QDesktopWidget().availableGeometry()
self.move(
(desktop.width() / 2) - (self.frameSize().width() / 2),
(desktop.height() / 2) - (self.frameSize().height() / 2),
)
示例8: show
def show(self):
self.visible = True
WindowBaseClass.show(self)
desktop = QDesktopWidget()
rect = desktop.availableGeometry(desktop.primaryScreen())
center = rect.center();
center.setX(center.x() - (self.width()/2));
center.setY(center.y() - (self.height()/2));
self.move(center);
示例9: setup
def setup(self, jid, talks, messages):
self.ui = Ui_conversationWindow()
self.talks = talks
self.messages = messages
self.ui.setupUi(jid, self)
desktopSize=QDesktopWidget().screenGeometry()
top=(desktopSize.height()/2)-(450/2)
left=(desktopSize.width()/2)-(300/2)
self.move(left, top)
示例10: __init__
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
desktopSize = QDesktopWidget().screenGeometry()
top=(desktopSize.height()/2)-(450/2)
left=(desktopSize.width()/2)-(300/2)
self.move(left, top)
self.connect(self.ui.friendsListWidget, QtCore.SIGNAL('itemDoubleClicked (QListWidgetItem *)'), self.openConversation)
self.talks = dict()
self.messages = collections.defaultdict(list)
示例11: __init__
def __init__(self, parent):
super(aboutWidget, self).__init__()
#Set popup
self.setWindowFlags(Qt.Popup)
self.resize(parent.meter.width(), 307)
self.setWindowOpacity(0.5)
#Move aboutWidget
if parent.isFullScreen():
resolution = QDesktopWidget().screenGeometry()
self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
(resolution.height() / 2) - (self.frameSize().height() / 2))
else:
point = parent.meter.rect().topRight()
global_point = parent.meter.mapToGlobal(point)
self.move(global_point - QPoint(self.width(), 0))
#Create vertical layout
vbox = QVBoxLayout(self)
#Set align and margins
if parent.isFullScreen():
vbox.setAlignment(Qt.AlignLeft)
vbox.setContentsMargins(150, 0, 0, 0)
else:
vbox.setAlignment(Qt.AlignHCenter)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
#LABELS
#name and version
label_name = QLabel('%s (%s)' % (__prj__, __version__))
label_name.setObjectName('name')
#label_url
label_url = QLabel(
'Source: <a style="color:orange" href="%s">Github repository</a>' % (__source__))
#label_license
label_license = QLabel('License: %s' % (__license__))
#label_author
label_author = QLabel(__author__)
label_author.setObjectName('author')
#Add widget to vbox
vbox.addWidget(label_name)
vbox.addWidget(label_license)
vbox.addWidget(label_url)
vbox.addWidget(label_author)
self.setLayout(vbox)
示例12: isWindowContainedInAnyOfAvailableDesktops
def isWindowContainedInAnyOfAvailableDesktops(window_position):
from PyQt4.QtGui import QDesktopWidget
from PyQt4.QtCore import QRect,QPoint
window_x, window_y = window_position
desktopWidget = QDesktopWidget()
#nScreens = desktopWidget.numScreens()
closestScreenIndex = desktopWidget.screenNumber(QPoint(window_x,window_y))
closestScreenDimensions = desktopWidget.availableGeometry(closestScreenIndex)
x_in_screen = window_x <= (closestScreenDimensions.x() + closestScreenDimensions.width()) and window_x >= closestScreenDimensions.x()
y_in_screen = window_y <= (closestScreenDimensions.y() + closestScreenDimensions.height()) and window_y >= closestScreenDimensions.y()
return x_in_screen and y_in_screen
示例13: center
def center(self):
"""
Move the Document viewer to the center of the screen.
"""
# Get the current screens' dimensions...
screen = QDesktopWidget().availableGeometry()
# ... and get this windows' dimensions
mdi_area_size = self.frameGeometry()
# The horizontal position
hpos = (screen.width() - mdi_area_size.width()) / 2
# vertical position
vpos = (screen.height() - mdi_area_size.height()) / 2
# repositions the window
self.move(hpos, vpos)
示例14: __init__
def __init__(self, parent=None):
super(Client, self).__init__(parent)
self.tab_widget = TabClass.TabWidget(self)
self.setWindowTitle('Book Library')
self.setCentralWidget(self.tab_widget)
dw = QDesktopWidget()
x = dw.width() * 0.7
y = dw.height() * 0.7
self.resize(x, y)
self.make_menu()
self.show()
示例15: centerWindow
def centerWindow(window):
rect = QDesktopWidget().screenGeometry()
width = 0
heigth = 0
if rect.width <= 640: width = 620
elif rect.width <= 800: width = 720
else: width = 960
if rect.height <= 480: height = 450
elif rect.height <= 600: height = 520
else: height = 680
window.resize(width, height)
window.move(rect.width()/2 - window.width()/2, rect.height()/2 - window.height()/2)