本文整理汇总了Python中AnyQt.QtCore.QSize.height方法的典型用法代码示例。如果您正苦于以下问题:Python QSize.height方法的具体用法?Python QSize.height怎么用?Python QSize.height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QSize
的用法示例。
在下文中一共展示了QSize.height方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sizeHint
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
def sizeHint(self):
"""
Reimplemented from `QPushButton.sizeHint`.
Returns
-------
sh : QSize
"""
sh = super().sizeHint()
option = QStyleOptionButton()
self.initStyleOption(option)
style = self.style()
fm = option.fontMetrics
if option.iconSize.isValid():
icsize = option.iconSize
icsize.setWidth(icsize.width() + 4)
else:
icsize = QSize()
for text in self.__textChoiceList:
option.text = text
size = fm.size(Qt.TextShowMnemonic, text)
if not icsize.isNull():
size.setWidth(size.width() + icsize.width())
size.setHeight(max(size.height(), icsize.height()))
sh = sh.expandedTo(
style.sizeFromContents(QStyle.CT_PushButton, option,
size, self))
return sh
示例2: __updatePixmap
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
def __updatePixmap(self):
"""
Update the cached shadow pixmap.
"""
rect_size = QSize(50, 50)
left = top = right = bottom = self.radius_
# Size of the pixmap.
pixmap_size = QSize(rect_size.width() + left + right,
rect_size.height() + top + bottom)
shadow_rect = QRect(QPoint(left, top), rect_size)
pixmap = QPixmap(pixmap_size)
pixmap.fill(QColor(0, 0, 0, 0))
rect_fill_color = self.palette().color(QPalette.Window)
pixmap = render_drop_shadow_frame(
pixmap,
QRectF(shadow_rect),
shadow_color=self.color_,
offset=QPointF(0, 0),
radius=self.radius_,
rect_fill_color=rect_fill_color
)
self.__shadowPixmap = pixmap
self.update()
示例3: sizeHint
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
def sizeHint(self):
hint = self.__contentsLayout.sizeHint()
if self.count():
# Compute max width of hidden widgets also.
scroll = self.__scrollArea
scroll_w = scroll.verticalScrollBar().sizeHint().width()
frame_w = self.frameWidth() * 2 + scroll.frameWidth() * 2
max_w = max([p.widget.sizeHint().width() for p in self.__pages])
hint = QSize(max(max_w, hint.width()) + scroll_w + frame_w,
hint.height())
return QSize(200, 200).expandedTo(hint)
示例4: _updateShadowPixmap
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
def _updateShadowPixmap(self):
"""Update the cached drop shadow pixmap.
"""
# Rectangle casting the shadow
rect_size = QSize(*CACHED_SHADOW_RECT_SIZE)
left, top, right, bottom = self.getContentsMargins()
# Size of the pixmap.
pixmap_size = QSize(rect_size.width() + left + right,
rect_size.height() + top + bottom)
shadow_rect = QRect(QPoint(left, top), rect_size)
pixmap = QPixmap(pixmap_size)
pixmap.fill(QColor(0, 0, 0, 0))
rect_fill_color = self.palette().color(QPalette.Window)
pixmap = render_drop_shadow_frame(pixmap, QRectF(shadow_rect),
shadow_color=self.color,
offset=self.offset,
radius=self.radius,
rect_fill_color=rect_fill_color)
self._shadowPixmap = pixmap
示例5: GraphicsIconItem
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
class GraphicsIconItem(QGraphicsItem):
"""
A graphics item displaying an :class:`QIcon`.
"""
def __init__(self, parent=None, icon=None, iconSize=None, **kwargs):
QGraphicsItem.__init__(self, parent, **kwargs)
self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption, True)
if icon is None:
icon = QIcon()
if iconSize is None:
style = QApplication.instance().style()
size = style.pixelMetric(style.PM_LargeIconSize)
iconSize = QSize(size, size)
self.__transformationMode = Qt.SmoothTransformation
self.__iconSize = QSize(iconSize)
self.__icon = QIcon(icon)
def setIcon(self, icon):
"""
Set the icon (:class:`QIcon`).
"""
if self.__icon != icon:
self.__icon = QIcon(icon)
self.update()
def icon(self):
"""
Return the icon (:class:`QIcon`).
"""
return QIcon(self.__icon)
def setIconSize(self, size):
"""
Set the icon (and this item's) size (:class:`QSize`).
"""
if self.__iconSize != size:
self.prepareGeometryChange()
self.__iconSize = QSize(size)
self.update()
def iconSize(self):
"""
Return the icon size (:class:`QSize`).
"""
return QSize(self.__iconSize)
def setTransformationMode(self, mode):
"""
Set pixmap transformation mode. (`Qt.SmoothTransformation` or
`Qt.FastTransformation`).
"""
if self.__transformationMode != mode:
self.__transformationMode = mode
self.update()
def transformationMode(self):
"""
Return the pixmap transformation mode.
"""
return self.__transformationMode
def boundingRect(self):
return QRectF(0, 0, self.__iconSize.width(), self.__iconSize.height())
def paint(self, painter, option, widget=None):
if not self.__icon.isNull():
if option.state & QStyle.State_Selected:
mode = QIcon.Selected
elif option.state & QStyle.State_Enabled:
mode = QIcon.Normal
elif option.state & QStyle.State_Active:
mode = QIcon.Active
else:
mode = QIcon.Disabled
w, h = self.__iconSize.width(), self.__iconSize.height()
target = QRect(0, 0, w, h)
painter.setRenderHint(
QPainter.SmoothPixmapTransform,
self.__transformationMode == Qt.SmoothTransformation
)
self.__icon.paint(painter, target, Qt.AlignCenter, mode)
示例6: sizeHint
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
def sizeHint(self, option, index):
size = QStyledItemDelegate.sizeHint(self, option, index)
size = QSize(size.width(), size.height() + 4)
return size
示例7: __layout
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
def __layout(self):
# position itself over `widget`
widget = self.__widget
if widget is None:
return
alignment = self.__alignment
policy = self.sizePolicy()
if widget.isWindow():
bounds = widget.geometry()
else:
bounds = QRect(widget.mapToGlobal(QPoint(0, 0)),
widget.size())
if self.isWindow():
bounds = bounds
else:
bounds = QRect(self.parent().mapFromGlobal(bounds.topLeft()),
bounds.size())
sh = self.sizeHint()
minsh = self.minimumSizeHint()
minsize = self.minimumSize()
if minsize.isNull():
minsize = minsh
maxsize = bounds.size().boundedTo(self.maximumSize())
minsize = minsize.boundedTo(maxsize)
effectivesh = sh.expandedTo(minsize).boundedTo(maxsize)
hpolicy = policy.horizontalPolicy()
vpolicy = policy.verticalPolicy()
def getsize(hint, minimum, maximum, policy):
if policy == QSizePolicy.Ignored:
return maximum
elif policy & QSizePolicy.ExpandFlag:
return maximum
else:
return max(hint, minimum)
width = getsize(effectivesh.width(), minsize.width(),
maxsize.width(), hpolicy)
heightforw = self.heightForWidth(width)
if heightforw > 0:
height = getsize(heightforw, minsize.height(),
maxsize.height(), vpolicy)
else:
height = getsize(effectivesh.height(), minsize.height(),
maxsize.height(), vpolicy)
size = QSize(width, height)
if alignment & Qt.AlignLeft:
x = bounds.x()
elif alignment & Qt.AlignRight:
x = bounds.right() - size.width()
else:
x = bounds.x() + max(0, bounds.width() - size.width()) // 2
if alignment & Qt.AlignTop:
y = bounds.y()
elif alignment & Qt.AlignBottom:
y = bounds.bottom() - size.height()
else:
y = bounds.y() + max(0, bounds.height() - size.height()) // 2
geom = QRect(QPoint(x, y), size)
self.setGeometry(geom)
示例8: GraphicsIconItem
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
class GraphicsIconItem(QGraphicsWidget):
"""
A graphics item displaying an :class:`QIcon`.
"""
def __init__(self, parent=None, icon=None, iconSize=None, **kwargs):
QGraphicsItem.__init__(self, parent, **kwargs)
self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption, True)
if icon is None:
icon = QIcon()
if iconSize is None:
style = QApplication.instance().style()
size = style.pixelMetric(style.PM_LargeIconSize)
iconSize = QSize(size, size)
self.__transformationMode = Qt.SmoothTransformation
self.__iconSize = QSize(iconSize)
self.__icon = QIcon(icon)
self._opacity = 1
self.anim = QPropertyAnimation(self, b"opacity")
self.anim.setDuration(350)
self.anim.setStartValue(1)
self.anim.setKeyValueAt(0.5, 0)
self.anim.setEndValue(1)
self.anim.setEasingCurve(QEasingCurve.OutQuad)
self.anim.setLoopCount(5)
def setIcon(self, icon):
"""
Set the icon (:class:`QIcon`).
"""
if self.__icon != icon:
self.__icon = QIcon(icon)
self.update()
def getOpacity(self):
return self._opacity
def setOpacity(self, o):
self._opacity = o
self.update()
opacity = Property(float, fget=getOpacity, fset=setOpacity)
def icon(self):
"""
Return the icon (:class:`QIcon`).
"""
return QIcon(self.__icon)
def setIconSize(self, size):
"""
Set the icon (and this item's) size (:class:`QSize`).
"""
if self.__iconSize != size:
self.prepareGeometryChange()
self.__iconSize = QSize(size)
self.update()
def iconSize(self):
"""
Return the icon size (:class:`QSize`).
"""
return QSize(self.__iconSize)
def setTransformationMode(self, mode):
"""
Set pixmap transformation mode. (`Qt.SmoothTransformation` or
`Qt.FastTransformation`).
"""
if self.__transformationMode != mode:
self.__transformationMode = mode
self.update()
def transformationMode(self):
"""
Return the pixmap transformation mode.
"""
return self.__transformationMode
def boundingRect(self):
return QRectF(0, 0, self.__iconSize.width(), self.__iconSize.height())
def paint(self, painter, option, widget=None):
if not self.__icon.isNull():
if option.state & QStyle.State_Selected:
mode = QIcon.Selected
elif option.state & QStyle.State_Enabled:
mode = QIcon.Normal
elif option.state & QStyle.State_Active:
mode = QIcon.Active
else:
mode = QIcon.Disabled
w, h = self.__iconSize.width(), self.__iconSize.height()
target = QRect(0, 0, w, h)
#.........这里部分代码省略.........
示例9: GraphicsIconItem
# 需要导入模块: from AnyQt.QtCore import QSize [as 别名]
# 或者: from AnyQt.QtCore.QSize import height [as 别名]
class GraphicsIconItem(QGraphicsItem):
"""
A graphics item displaying an :class:`QIcon`.
"""
def __init__(self, parent=None, icon=None, iconSize=None, **kwargs):
QGraphicsItem.__init__(self, parent, **kwargs)
self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption, True)
if icon is None:
icon = QIcon()
if iconSize is None:
style = QApplication.instance().style()
size = style.pixelMetric(style.PM_LargeIconSize)
iconSize = QSize(size, size)
self.__transformationMode = Qt.SmoothTransformation
self.__iconSize = QSize(iconSize)
self.__icon = QIcon(icon)
def setIcon(self, icon):
"""
Set the icon (:class:`QIcon`).
"""
if self.__icon != icon:
self.__icon = QIcon(icon)
self.update()
def icon(self):
"""
Return the icon (:class:`QIcon`).
"""
return QIcon(self.__icon)
def setIconSize(self, size):
"""
Set the icon (and this item's) size (:class:`QSize`).
"""
if self.__iconSize != size:
self.prepareGeometryChange()
self.__iconSize = QSize(size)
self.update()
def iconSize(self):
"""
Return the icon size (:class:`QSize`).
"""
return QSize(self.__iconSize)
def setTransformationMode(self, mode):
"""
Set pixmap transformation mode. (`Qt.SmoothTransformation` or
`Qt.FastTransformation`).
"""
if self.__transformationMode != mode:
self.__transformationMode = mode
self.update()
def transformationMode(self):
"""
Return the pixmap transformation mode.
"""
return self.__transformationMode
def boundingRect(self):
return QRectF(0, 0, self.__iconSize.width(), self.__iconSize.height())
def paint(self, painter, option, widget=None):
if not self.__icon.isNull():
if option.state & QStyle.State_Selected:
mode = QIcon.Selected
elif option.state & QStyle.State_Enabled:
mode = QIcon.Normal
elif option.state & QStyle.State_Active:
mode = QIcon.Active
else:
mode = QIcon.Disabled
transform = self.sceneTransform()
if widget is not None:
# 'widget' is the QGraphicsView.viewport()
view = widget.parent()
if isinstance(view, QGraphicsView):
# Combine the scene transform with the view transform.
view_transform = view.transform()
transform = view_transform * view_transform
lod = option.levelOfDetailFromTransform(transform)
w, h = self.__iconSize.width(), self.__iconSize.height()
target = QRectF(0, 0, w, h)
source = QRectF(0, 0, w * lod, w * lod).toRect()
# The actual size of the requested pixmap can be smaller.
size = self.__icon.actualSize(source.size(), mode=mode)
source.setSize(size)
#.........这里部分代码省略.........