本文整理汇总了Python中spyderlib.qt.QtGui.QApplication.desktop方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.desktop方法的具体用法?Python QApplication.desktop怎么用?Python QApplication.desktop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QApplication
的用法示例。
在下文中一共展示了QApplication.desktop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_list
# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import desktop [as 别名]
def show_list(self, completion_list, automatic=True):
if len(completion_list) == 1 and not automatic:
self.textedit.insert_completion(completion_list[0])
return
self.completion_list = completion_list
self.clear()
self.addItems(completion_list)
self.setCurrentRow(0)
QApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
self.show()
self.setFocus()
self.raise_()
# Retrieving current screen height
desktop = QApplication.desktop()
srect = desktop.availableGeometry(desktop.screenNumber(self))
screen_right = srect.right()
screen_bottom = srect.bottom()
point = self.textedit.cursorRect().bottomRight()
point.setX(point.x()+self.textedit.get_linenumberarea_width())
point = self.textedit.mapToGlobal(point)
# Computing completion widget and its parent right positions
comp_right = point.x()+self.width()
ancestor = self.parent()
if ancestor is None:
anc_right = screen_right
else:
anc_right = min([ancestor.x()+ancestor.width(), screen_right])
# Moving completion widget to the left
# if there is not enough space to the right
if comp_right > anc_right:
point.setX(point.x()-self.width())
# Computing completion widget and its parent bottom positions
comp_bottom = point.y()+self.height()
ancestor = self.parent()
if ancestor is None:
anc_bottom = screen_bottom
else:
anc_bottom = min([ancestor.y()+ancestor.height(), screen_bottom])
# Moving completion widget above if there is not enough space below
x_position = point.x()
if comp_bottom > anc_bottom:
point = self.textedit.cursorRect().topRight()
point = self.textedit.mapToGlobal(point)
point.setX(x_position)
point.setY(point.y()-self.height())
if ancestor is not None:
# Useful only if we set parent to 'ancestor' in __init__
point = ancestor.mapFromGlobal(point)
self.move(point)
if to_text_string(self.textedit.completion_text):
# When initialized, if completion text is not empty, we need
# to update the displayed list:
self.update_current()