本文整理汇总了Python中AnyQt.QtGui.QPixmap.fill方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.fill方法的具体用法?Python QPixmap.fill怎么用?Python QPixmap.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.fill方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: decorate_welcome_icon
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [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: __updatePixmap
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [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: pixmap
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def pixmap(self, size, mode, state):
# type: (QSize, QIcon.Mode, QIcon.State) -> QPixmap
if not self.__generator.isValid():
return QPixmap()
dsize = self.__generator.defaultSize() # type: QSize
if not dsize.isNull():
dsize.scale(size, Qt.KeepAspectRatio)
size = dsize
key = "{}.SVGIconEngine/{}/{}x{}".format(
__name__, self.__cache_id, size.width(), size.height()
)
pm = QPixmapCache.find(key)
if pm is None or pm.isNull():
pm = QPixmap(size)
pm.fill(Qt.transparent)
painter = QPainter(pm)
try:
self.__generator.render(
painter, QRectF(0, 0, size.width(), size.height()))
finally:
painter.end()
QPixmapCache.insert(key, pm)
style = QApplication.style()
if style is not None:
opt = QStyleOption()
opt.palette = QApplication.palette()
pm = style.generatedIconPixmap(mode, pm, opt)
return pm
示例4: palette_pixmap
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def palette_pixmap(colors, size):
img = QPixmap(size)
img.fill(Qt.transparent)
painter = QPainter(img)
grad = palette_gradient(colors)
grad.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
painter.setPen(Qt.NoPen)
painter.setBrush(QBrush(grad))
painter.drawRect(0, 0, size.width(), size.height())
painter.end()
return img
示例5: update_legend
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def update_legend(self, colors, labels):
layout = self.legend.layout()
while self.legend_items:
w = self.legend_items.pop()
layout.removeWidget(w)
w.deleteLater()
for row, (color, label) in enumerate(zip(colors, labels)):
icon = QLabel()
p = QPixmap(12, 12)
p.fill(color)
icon.setPixmap(p)
label = QLabel(label)
layout.addWidget(icon, row, 0)
layout.addWidget(label, row, 1, alignment=Qt.AlignLeft)
self.legend_items += (icon, label)
示例6: init_combos
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def init_combos():
"""
function initialize the combos with attributes
"""
reset_combos()
c_vars = [var for var in data.domain.variables if var.is_continuous]
self.x_var_model[:] = c_vars
self.y_var_model[:] = c_vars
for i, var in enumerate(data.domain.class_var.values):
pix_map = QPixmap(60, 60)
color = tuple(data.domain.class_var.colors[i].tolist())
pix_map.fill(QColor(*color))
self.target_class_combobox.addItem(QIcon(pix_map), var)
示例7: crosshairs
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def crosshairs(color, radius=24, circle=False):
radius = max(radius, 16)
pixmap = QPixmap(radius, radius)
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
painter.setRenderHints(QPainter.Antialiasing)
pen = QPen(QBrush(color), 1)
pen.setWidthF(1.5)
painter.setPen(pen)
if circle:
painter.drawEllipse(2, 2, radius - 2, radius - 2)
painter.drawLine(radius / 2, 7, radius / 2, radius / 2 - 7)
painter.drawLine(7, radius / 2, radius / 2 - 7, radius / 2)
painter.end()
return pixmap
示例8: __startInternalDrag
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def __startInternalDrag(self, frame, hotSpot=None):
drag = QDrag(self)
pixmap = QPixmap(frame.size())
frame.render(pixmap)
transparent = QPixmap(pixmap.size())
transparent.fill(Qt.transparent)
painter = QPainter(transparent)
painter.setOpacity(0.35)
painter.drawPixmap(0, 0, pixmap.width(), pixmap.height(), pixmap)
painter.end()
drag.setPixmap(transparent)
if hotSpot is not None:
drag.setHotSpot(hotSpot)
mime = QMimeData()
mime.setData("application/x-internal-move", b"")
drag.setMimeData(mime)
return drag.exec_(Qt.MoveAction)
示例9: init_combos
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def init_combos():
"""
function initialize the combos with attributes
"""
reset_combos()
c_vars = [var for var in d.domain.attributes if var.is_continuous]
self.x_var_model[:] = c_vars
self.y_var_model[:] = c_vars if self.is_logistic else []
for i, var in (enumerate(d.domain.class_var.values)
if d.domain.class_var.is_discrete else []):
pix_map = QPixmap(60, 60)
color = tuple(d.domain.class_var.colors[i].tolist())
pix_map.fill(QColor(*color))
self.target_class_combobox.addItem(QIcon(pix_map), var)
self.cby.setDisabled(not self.is_logistic)
self.target_class_combobox.setDisabled(not self.is_logistic)
示例10: _updateShadowPixmap
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [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
示例11: setHistogram
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def setHistogram(self, values=None, bins=None, use_kde=False, histogram=None):
""" Set background histogram (or density estimation, violin plot)
The histogram of bins is calculated from values, optionally as a
Gaussian KDE. If histogram is provided, its values are used directly
and other parameters are ignored.
"""
if (values is None or not len(values)) and histogram is None:
self.setPixmap(None)
return
if histogram is not None:
self._histogram = hist = histogram
else:
if bins is None:
bins = min(100, max(10, len(values) // 20))
if use_kde:
hist = gaussian_kde(values,
None if isinstance(use_kde, bool) else use_kde)(
np.linspace(np.min(values), np.max(values), bins))
else:
hist = np.histogram(values, bins)[0]
self._histogram = hist = hist / hist.max()
HEIGHT = self.rect().height() / 2
OFFSET = HEIGHT * .3
pixmap = QPixmap(QSize(len(hist), 2 * (HEIGHT + OFFSET))) # +1 avoids right/bottom frame border shadow
pixmap.fill(Qt.transparent)
painter = QPainter(pixmap)
painter.setPen(QPen(Qt.darkGray))
for x, value in enumerate(hist):
painter.drawLine(x, HEIGHT * (1 - value) + OFFSET,
x, HEIGHT * (1 + value) + OFFSET)
if self.orientation() != Qt.Horizontal:
pixmap = pixmap.transformed(QTransform().rotate(-90))
self.setPixmap(pixmap)
示例12: pixmap
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def pixmap(self, size, mode, state):
# type: (QSize, QIcon.Mode, QIcon.State) -> QPixmap
if not self.__generator.isValid():
return QPixmap()
dsize = self.__generator.defaultSize() # type: QSize
if not dsize.isNull():
dsize.scale(size, Qt.KeepAspectRatio)
size = dsize
pm = QPixmap(size)
pm.fill(Qt.transparent)
painter = QPainter(pm)
try:
self.__generator.render(
painter, QRectF(0, 0, size.width(), size.height()))
finally:
painter.end()
style = QApplication.style()
if style is not None:
opt = QStyleOption()
opt.palette = QApplication.palette()
pm = style.generatedIconPixmap(mode, pm, opt)
return pm
示例13: __init__
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import fill [as 别名]
def __init__(self, color=QColor(Qt.white), size=12):
p = QPixmap(size, size)
p.fill(color)
self.color = color
QIcon.__init__(self, p)