本文整理汇总了Python中qtpy.QtGui.QPixmap.fill方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.fill方法的具体用法?Python QPixmap.fill怎么用?Python QPixmap.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.fill方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_color
# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fill [as 别名]
def set_color(self, color):
if color != self._color:
self._color = color
self.colorChanged.emit(self._color)
pixmap = QPixmap(self.iconSize())
pixmap.fill(color)
self.setIcon(QIcon(pixmap))
示例2: MapGraphicsScene
# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fill [as 别名]
class MapGraphicsScene(QGraphicsScene):
"""Graphics scene for showing a slippy map.
"""
sigZoomChanged = Signal(int)
def __init__(self, tileSource, parent=None):
"""Constructor.
Args:
tileSource(MapTileSource): Source for loading the tiles.
parent(QObject): Parent object, default `None`
"""
QGraphicsScene.__init__(self, parent=parent)
self._zoom = 15
self._tileSource = tileSource
self._tileSource.setParent(self)
self._tileSource.tileReceived.connect(self.setTilePixmap)
tdim = self._tileSource.tileSize()
self._emptyTile = QPixmap(tdim, tdim)
self._emptyTile.fill(Qt.lightGray)
self._tilesRect = QRect()
self._tilePixmaps = {}
self._tileInDownload = list()
self.setSceneRect(0.0, 0.0, 400, 300)
self.sceneRectChanged.connect(self.onSceneRectChanged)
@Slot()
def close(self):
self._tileSource.close()
def setTileSource(self, newTileSource):
self._tileSource.tileReceived.disconnect(self.setTilePixmap)
self._tileSource.close()
self._tilePixmaps.clear()
self._tileInDownload = list()
self._tileSource = newTileSource
self._tileSource.setParent(self)
self._tileSource.tileReceived.connect(self.setTilePixmap)
self.requestTiles()
self.invalidate()
self.update()
@Slot(QRectF)
def onSceneRectChanged(self, rect):
"""Callback for the changing of the visible rect.
Evaluate the visible tiles and request to load the new tiles.
Args:
rect(QRectF): Current visible area.
"""
tdim = self._tileSource.tileSize()
center = rect.center()
ct = self.tileFromPos(center.x(), center.y())
tx = ct.x()
ty = ct.y()
width = rect.width()
height = rect.height()
# top left corner of the center tile
xp = int(width / 2.0 - (tx - floor(tx)) * tdim)
yp = int(height / 2.0 - (ty - floor(ty)) * tdim)
# first tile vertical and horizontal
xs = tx - (xp + tdim - 1) / tdim
ys = ty - (yp + tdim - 1) / tdim
# last tile vertical and horizontal
xe = (width - xp - 1) / tdim - xs + 1 + tx
ye = (height - yp - 1) / tdim - ys + 1 + ty
# define the rect of visible tiles
self._tilesRect = QRect(xs, ys, xe, ye)
# Request the loading of new tiles (if needed)
self.requestTiles()
self.invalidate()
self.update()
def drawBackground(self, painter, rect):
"""Draw the background tiles.
If a tile is not available, draw a gray rectangle.
Args:
painter(QPainter): Painter for drawing.
rect(QRectF): Current visible area.
"""
#.........这里部分代码省略.........
示例3: pixmap
# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fill [as 别名]
def pixmap(self, size, mode, state):
pm = QPixmap(size)
pm.fill(Qt.transparent)
self.paint(QPainter(pm), QRect(QPoint(0, 0), size), mode, state)
return pm
示例4: __init__
# 需要导入模块: from qtpy.QtGui import QPixmap [as 别名]
# 或者: from qtpy.QtGui.QPixmap import fill [as 别名]
def __init__(self):
QMainWindow.__init__(self)
view = MapGraphicsView(tileSource=MapTileSourceHere())
self.setCentralWidget(view)
view.scene().setCenter(10.065990, 44.861041)
view.setOptimizationFlag(QGraphicsView.DontSavePainterState, True)
view.setRenderHint(QPainter.Antialiasing, True)
view.setRenderHint(QPainter.SmoothPixmapTransform, True)
pointItem = view.scene().addCircle(10.068640, 44.860767, 3.0)
pointItem.setBrush(Qt.black)
pointItem.setToolTip('10.068640, 44.860767')
pointItem.setFlag(QGraphicsItem.ItemIsSelectable, True)
lats = list()
lons = list()
for p in POINTS:
pointItem = view.scene().addCircle(p[1], p[0], 5.0)
pointItem.setBrush(Qt.green)
pointItem.setPen(QPen(Qt.NoPen))
pointItem.setToolTip('%f, %f' % (p[1], p[0]))
pointItem.setFlag(QGraphicsItem.ItemIsSelectable, True)
lons.append(p[1])
lats.append(p[0])
lineItem = view.scene().addLine(10.191037, 44.832810, 10.201736, 44.837632)
lineItem.setPen(QPen(QBrush(Qt.blue), 3.0))
polylineItem = view.scene().addPolyline(lons, lats)
polylineItem.setPen(QPen(QBrush(Qt.red), 3.0))
pix = QPixmap(24, 24)
pix.fill(Qt.red)
pixmapItem = view.scene().addPixmap(10.090598, 44.857893, pix)
pixmapItem.setOffset(-12, -12)
pointItemPixmapOrigin = view.scene().addCircle(10.090598, 44.857893, 3.0)
pointItemPixmapOrigin.setBrush(Qt.black)
pointItemWithChild = view.scene().addCircle(10.083103, 44.858014, 3.0)
pointItemWithChild.setBrush(Qt.blue)
pointItemWithChild.setPen(QPen(Qt.NoPen))
textItem = QGraphicsSimpleTextItem('Annotation\nfor blue point', parent=pointItemWithChild)
textItem.setBrush(QBrush(QColor(Qt.blue)))
textItem.setPos(-5, 3)
lats_2 = list()
lons_2 = list()
for p in POINTS_2:
lons_2.append(p[1])
lats_2.append(p[0])
linesGroupItem = view.scene().addLinesGroup(lons_2, lats_2)
linesGroupItem.setLineStyle(POINTS_2_COLORS, width=POINTS_2_SIZES)
legendItem = view.scene().addLegend()
legendItem.addPoint('Point 1', '#FF0000', border=None)
legendItem.addRect('Rect 2', '#00FF00', border=None)
legendItem.addPoint('Circle 3', '#0000FF', border=None)
legendItem.addRect('Sphere 4', '#00FFFF', border=None)
legendItem.addPoint('Polygon 5', '#FF00FF', border=None)
scaleItem = view.scene().addScale(anchor=Qt.BottomRightCorner)