本文整理匯總了Python中AnyQt.QtGui.QIcon.addPixmap方法的典型用法代碼示例。如果您正苦於以下問題:Python QIcon.addPixmap方法的具體用法?Python QIcon.addPixmap怎麽用?Python QIcon.addPixmap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AnyQt.QtGui.QIcon
的用法示例。
在下文中一共展示了QIcon.addPixmap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: decorate_welcome_icon
# 需要導入模塊: from AnyQt.QtGui import QIcon [as 別名]
# 或者: from AnyQt.QtGui.QIcon import addPixmap [as 別名]
def decorate_welcome_icon(icon, background_color):
"""Return a `QIcon` with a circle shaped background.
"""
welcome_icon = QIcon()
sizes = [32, 48, 64, 80, 128, 256]
background_color = NAMED_COLORS.get(background_color, background_color)
background_color = QColor(background_color)
grad = radial_gradient(background_color)
for size in sizes:
icon_size = QSize(5 * size / 8, 5 * size / 8)
icon_rect = QRect(QPoint(0, 0), icon_size)
pixmap = QPixmap(size, size)
pixmap.fill(Qt.transparent)
p = QPainter(pixmap)
p.setRenderHint(QPainter.Antialiasing, True)
p.setBrush(QBrush(grad))
p.setPen(Qt.NoPen)
ellipse_rect = QRect(0, 0, size, size)
p.drawEllipse(ellipse_rect)
icon_rect.moveCenter(ellipse_rect.center())
icon.paint(p, icon_rect, Qt.AlignCenter, )
p.end()
welcome_icon.addPixmap(pixmap)
return welcome_icon
示例2: __init__
# 需要導入模塊: from AnyQt.QtGui import QIcon [as 別名]
# 或者: from AnyQt.QtGui.QIcon import addPixmap [as 別名]
def __init__(self, *args, **kwargs):
QDockWidget.__init__(self, *args, **kwargs)
self.__expandedWidget = None
self.__collapsedWidget = None
self.__expanded = True
self.__trueMinimumWidth = -1
self.setFeatures(QDockWidget.DockWidgetClosable | \
QDockWidget.DockWidgetMovable)
self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.featuresChanged.connect(self.__onFeaturesChanged)
self.dockLocationChanged.connect(self.__onDockLocationChanged)
# Use the toolbar horizontal extension button icon as the default
# for the expand/collapse button
icon = self.style().standardIcon(
QStyle.SP_ToolBarHorizontalExtensionButton)
# Mirror the icon
transform = QTransform()
transform = transform.scale(-1.0, 1.0)
icon_rev = QIcon()
for s in (8, 12, 14, 16, 18, 24, 32, 48, 64):
pm = icon.pixmap(s, s)
icon_rev.addPixmap(pm.transformed(transform))
self.__iconRight = QIcon(icon)
self.__iconLeft = QIcon(icon_rev)
close = self.findChild(QAbstractButton,
name="qt_dockwidget_closebutton")
close.installEventFilter(self)
self.__closeButton = close
self.__stack = AnimatedStackedWidget()
self.__stack.setSizePolicy(QSizePolicy.Fixed,
QSizePolicy.Expanding)
self.__stack.transitionStarted.connect(self.__onTransitionStarted)
self.__stack.transitionFinished.connect(self.__onTransitionFinished)
QDockWidget.setWidget(self, self.__stack)
self.__closeButton.setIcon(self.__iconLeft)