本文整理汇总了Python中AnyQt.QtCore.QRect.setLeft方法的典型用法代码示例。如果您正苦于以下问题:Python QRect.setLeft方法的具体用法?Python QRect.setLeft怎么用?Python QRect.setLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRect
的用法示例。
在下文中一共展示了QRect.setLeft方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: popup
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import setLeft [as 别名]
def popup(self, pos=None, searchText=""):
"""
Popup the menu at `pos` (in screen coordinates). 'Search' text field
is initialized with `searchText` if provided.
"""
if pos is None:
pos = QPoint()
self.__clearCurrentItems()
self.__search.setText(searchText)
patt = QRegExp("(^|\W)"+searchText)
patt.setCaseSensitivity(False)
self.__suggestPage.setFilterRegExp(patt)
self.ensurePolished()
if self.testAttribute(Qt.WA_Resized) and self.sizeGripEnabled():
size = self.size()
else:
size = self.sizeHint()
desktop = QApplication.desktop()
screen_geom = desktop.availableGeometry(pos)
# Adjust the size to fit inside the screen.
if size.height() > screen_geom.height():
size.setHeight(screen_geom.height())
if size.width() > screen_geom.width():
size.setWidth(screen_geom.width())
geom = QRect(pos, size)
if geom.top() < screen_geom.top():
geom.setTop(screen_geom.top())
if geom.left() < screen_geom.left():
geom.setLeft(screen_geom.left())
bottom_margin = screen_geom.bottom() - geom.bottom()
right_margin = screen_geom.right() - geom.right()
if bottom_margin < 0:
# Falls over the bottom of the screen, move it up.
geom.translate(0, bottom_margin)
# TODO: right to left locale
if right_margin < 0:
# Falls over the right screen edge, move the menu to the
# other side of pos.
geom.translate(-size.width(), 0)
self.setGeometry(geom)
self.show()
if searchText:
self.setFocusProxy(self.__search)
else:
self.setFocusProxy(None)
示例2: widget_popup_geometry
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import setLeft [as 别名]
def widget_popup_geometry(pos, widget):
widget.ensurePolished()
if widget.testAttribute(Qt.WA_Resized):
size = widget.size()
else:
size = widget.sizeHint()
desktop = QApplication.desktop()
screen_geom = desktop.availableGeometry(pos)
# Adjust the size to fit inside the screen.
if size.height() > screen_geom.height():
size.setHeight(screen_geom.height())
if size.width() > screen_geom.width():
size.setWidth(screen_geom.width())
geom = QRect(pos, size)
if geom.top() < screen_geom.top():
geom.setTop(screen_geom.top())
if geom.left() < screen_geom.left():
geom.setLeft(screen_geom.left())
bottom_margin = screen_geom.bottom() - geom.bottom()
right_margin = screen_geom.right() - geom.right()
if bottom_margin < 0:
# Falls over the bottom of the screen, move it up.
geom.translate(0, bottom_margin)
# TODO: right to left locale
if right_margin < 0:
# Falls over the right screen edge, move the menu to the
# other side of pos.
geom.translate(-size.width(), 0)
return geom
示例3: __paintEventNoStyle
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import setLeft [as 别名]
def __paintEventNoStyle(self):
p = QPainter(self)
opt = QStyleOptionToolButton()
self.initStyleOption(opt)
fm = QFontMetrics(opt.font)
palette = opt.palette
# highlight brush is used as the background for the icon and background
# when the tab is expanded and as mouse hover color (lighter).
brush_highlight = palette.highlight()
foregroundrole = QPalette.ButtonText
if opt.state & QStyle.State_Sunken:
# State 'down' pressed during a mouse press (slightly darker).
background_brush = brush_darker(brush_highlight, 110)
foregroundrole = QPalette.HighlightedText
elif opt.state & QStyle.State_MouseOver:
background_brush = brush_darker(brush_highlight, 95)
foregroundrole = QPalette.HighlightedText
elif opt.state & QStyle.State_On:
background_brush = brush_highlight
foregroundrole = QPalette.HighlightedText
else:
# The default button brush.
background_brush = palette.button()
rect = opt.rect
icon_area_rect = QRect(rect)
icon_area_rect.setRight(int(icon_area_rect.height() * 1.26))
text_rect = QRect(rect)
text_rect.setLeft(icon_area_rect.right() + 10)
# Background (TODO: Should the tab button have native
# toolbutton shape, drawn using PE_PanelButtonTool or even
# QToolBox tab shape)
# Default outline pen
pen = QPen(palette.color(QPalette.Mid))
p.save()
p.setPen(Qt.NoPen)
p.setBrush(QBrush(background_brush))
p.drawRect(rect)
# Draw the background behind the icon if the background_brush
# is different.
if not opt.state & QStyle.State_On:
p.setBrush(brush_highlight)
p.drawRect(icon_area_rect)
# Line between the icon and text
p.setPen(pen)
p.drawLine(icon_area_rect.topRight(),
icon_area_rect.bottomRight())
if opt.state & QStyle.State_HasFocus:
# Set the focus frame pen and draw the border
pen = QPen(QColor(FOCUS_OUTLINE_COLOR))
p.setPen(pen)
p.setBrush(Qt.NoBrush)
# Adjust for pen
rect = rect.adjusted(0, 0, -1, -1)
p.drawRect(rect)
else:
p.setPen(pen)
# Draw the top/bottom border
if self.position == QStyleOptionToolBox.OnlyOneTab or \
self.position == QStyleOptionToolBox.Beginning or \
self.selected & \
QStyleOptionToolBox.PreviousIsSelected:
p.drawLine(rect.topLeft(), rect.topRight())
p.drawLine(rect.bottomLeft(), rect.bottomRight())
p.restore()
p.save()
text = fm.elidedText(opt.text, Qt.ElideRight, text_rect.width())
p.setPen(QPen(palette.color(foregroundrole)))
p.setFont(opt.font)
p.drawText(text_rect,
int(Qt.AlignVCenter | Qt.AlignLeft) | \
int(Qt.TextSingleLine),
text)
if not opt.icon.isNull():
if opt.state & QStyle.State_Enabled:
mode = QIcon.Normal
else:
mode = QIcon.Disabled
if opt.state & QStyle.State_On:
state = QIcon.On
else:
state = QIcon.Off
icon_area_rect = icon_area_rect
icon_rect = QRect(QPoint(0, 0), opt.iconSize)
#.........这里部分代码省略.........