当前位置: 首页>>代码示例>>Python>>正文


Python QPixmap.fill方法代码示例

本文整理汇总了Python中PySide.QtGui.QPixmap.fill方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.fill方法的具体用法?Python QPixmap.fill怎么用?Python QPixmap.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QPixmap的用法示例。


在下文中一共展示了QPixmap.fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: drawIconWithShadow

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
    def drawIconWithShadow(icon, rect, p, iconMode, radius, color, offset):
        cache = QPixmap()
        pixmapName = "icon {0} {1} {2}".format(icon.cacheKey(), iconMode, rect.height())

        if not QPixmapCache.find(pixmapName, cache):
            px = icon.pixmap(rect.size())
            cache = QPixmap(px.size() + QSize(radius * 2, radius * 2))
            cache.fill(Qt.transparent)

            cachePainter = QPainter(cache)
            if iconMode == QIcon.Disabled:
                im = px.toImage().convertToFormat(QImage.Format_ARGB32)
                for y in range(im.height()):
                    scanLine = im.scanLine(y)
                    for x in range(im.width()):
                        pixel = scanLine
                        intensity = qGray(pixel)
                        scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel))
                        scanLine += 1
                px = QPixmap.fromImage(im)

            # Draw shadow
            tmp = QImage(px.size() + QSize(radius * 2, radius * 2 + 1), QImage.Format_ARGB32_Premultiplied)
            tmp.fill(Qt.transparent)

            tmpPainter = QPainter(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_Source)
            tmpPainter.drawPixmap(QPoint(radius, radius), px)
            tmpPainter.end()

            # blur the alpha channel
            blurred = QImage(tmp.size(), QImage.Format_ARGB32_Premultiplied)
            blurred.fill(Qt.transparent)
            blurPainter = QPainter(blurred)
            # todo : blur image
            blurPainter.end()

            tmp = blurred

            # blacken the image
            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            # draw the blurred drop shadow...
            cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp)

            # Draw the actual pixmap...
            cachePainter.drawPixmap(QPoint(radius, radius) + offset, px)
            QPixmapCache.insert(pixmapName, cache)

        targetRect = cache.rect()
        targetRect.moveCenter(rect.center())
        p.drawPixmap(targetRect.topLeft() - offset, cache)
开发者ID:nichollyn,项目名称:libspark,代码行数:62,代码来源:stylehelper.py

示例2: __init__

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
	def __init__(self, root_node, parent=None):
		super(AddDeviceDlg, self).__init__(parent)
		self.setWindowTitle("Add Relief Device")

		id_label = QLabel("&Relief Device ID:")
		self.id_lineedit = QLineEdit()
		self.id_lineedit.setMaxLength(200)
		id_label.setBuddy(self.id_lineedit)
		area_label = QLabel("Associated Relief Device &Area:")
		self.area_combobox = QComboBox()
		for area in root_node.children:
			self.area_combobox.addItem(area.name, area)
		area_label.setBuddy(self.area_combobox)
		color_label = QLabel("&Text Color:")
		self.color_combobox = QComboBox()
		for key in sorted(COLORS.keys()):
			pixmap = QPixmap(26, 26)
			pixmap.fill(COLORS[key])
			self.color_combobox.addItem(QIcon(pixmap), key)
		color_label.setBuddy(self.color_combobox)
		button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
			
		layout = QGridLayout()
		layout.addWidget(id_label, 0, 0)
		layout.addWidget(self.id_lineedit, 0, 1)
		layout.addWidget(area_label, 1, 0)
		layout.addWidget(self.area_combobox, 1, 1)
		layout.addWidget(color_label, 2, 0)
		layout.addWidget(self.color_combobox, 2, 1)
		layout.addWidget(button_box, 3, 1)
		self.setLayout(layout)
		
		button_box.accepted.connect(self.accept)
		button_box.rejected.connect(self.reject)
开发者ID:nb1987,项目名称:rvac,代码行数:36,代码来源:dlg_classes.py

示例3: _update_cursor

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
 def _update_cursor(self):
     x = self.diameter
     w, h = x, x
     pixmap = QPixmap(w, h)
     pixmap.fill(Qt.transparent)
     p = QPainter(pixmap)
     p.drawPoints(self._points)
     p.end()
     self._cursor_pixmap = pixmap.createMaskFromColor(Qt.transparent)
开发者ID:jthacker,项目名称:arrview,代码行数:11,代码来源:paintbrush.py

示例4: size_changed

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
    def size_changed(self, value):
        "Handle the slider drag event."

        size = self.ui.brush_demo_label.size()
        pixmap = QPixmap(100, 100)
        pixmap.fill(Qt.white)
        cx, cy = int(size.width() / 2), int(size.height() / 2)
        self.current_brush.set_size(value)
        self.current_brush.draw_marker(cx, cy, pixmap, 1)
        self.ui.brush_demo_label.setPixmap(pixmap)
开发者ID:fredo-editor,项目名称:FreDo,代码行数:12,代码来源:brush_dialog.py

示例5: x_bitmap_opaque

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
    def x_bitmap_opaque ( self, bitmap ):
        """ Returns a version of the specified bitmap with no transparency.
        """
        dx = bitmap.width()
        dy = bitmap.height()
        opaque_bitmap = QPixmap( dx, dy )
        opaque_bitmap.fill( WindowColor )
        q = QPainter( opaque_bitmap )
        q.drawPixmap( 0, 0, bitmap )

        return opaque_bitmap
开发者ID:davidmorrill,项目名称:facets,代码行数:13,代码来源:image_slice.py

示例6: choose_color

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
def choose_color():
    color  = QColorDialog().getColor()
    
    msgbox = QMessageBox()
    if color.isValid():
        pixmap = QPixmap(50, 50)
        pixmap.fill(color)
        msgbox.setWindowTitle(u'Selected Color')
        msgbox.setIconPixmap(pixmap)
    else:
        msgbox.setWindowTitle(u'No Color was Selected')
    msgbox.exec_()
开发者ID:eueung,项目名称:python,代码行数:14,代码来源:app5.py

示例7: __init__

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
    def __init__(self, dock):
        """Construct a DragDockLabel for the given dock."""
        super(DragDockLabel, self).__init__("Drag Me")

        self.dock = dock
        self.setAcceptDrops(True)
        self.setScaledContents(True)
        self.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
        self.setToolTip("Click and drag to change parent.")

        pm = QPixmap(1, 10)
        pm.fill(Qt.black)
        self.setPixmap(pm)
开发者ID:Schizo,项目名称:boxfish,代码行数:15,代码来源:ModuleFrame.py

示例8: choose_color

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
def choose_color():
    # Select color
    color = QColorDialog().getColor()
    
    # Report about result of selection in QMessageBox dialog
    msgbox = QMessageBox()
    if color.isValid():
        # Create a memory image 50x50 filled with selected color to display
        # as a icon in the msgbox dialog
        pixmap = QPixmap(50, 50)
        pixmap.fill(color)
        msgbox.setWindowTitle(u'Selected Color')
        msgbox.setIconPixmap(pixmap)
    else:
        msgbox.setWindowTitle(u'No Color was Selected')
    msgbox.exec_()
开发者ID:johngraham660,项目名称:PySideApp,代码行数:18,代码来源:PySideApp.py

示例9: createColors

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
    def createColors(self):
        for style in MOAIDebugDrawStyles:
            colorBtn = getattr(self.ui, style + "Color")
            colorBtn.color = QColor(255, 255, 255, 255)
            pixmap = QPixmap(16, 16)
            pixmap.fill(colorBtn.color)

            colorBtn.pixmap = pixmap
            colorBtn.setIcon(pixmap)
            colorBtn.setAutoFillBackground(False)
            colorBtn.setIconSize(QtCore.QSize(16, 16))
            def setColor(self, color):
                self.pixmap.fill(color)
                self.setIcon(self.pixmap)
                self.color = color

            colorBtn.setColor = types.MethodType(setColor, colorBtn)
开发者ID:Vavius,项目名称:moai-ide,代码行数:19,代码来源:debugdock.py

示例10: generateCursor

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
 def generateCursor(self, element):
     cursorPixmap = QPixmap(32,32)
     hotX = element.getAttribute('__hotX')
     if hotX == None:
         hotX = element.width()/2
     hotY = element.getAttribute('__hotY')
     if hotY == None:
         hotY = element.height()/2
     cursorPixmap.fill(Qt.transparent)
     element.moveTo(0,0)
     painter = QPainter()
     painter.begin(cursorPixmap)
     id = element.getAttribute('id')
     assert id != None and isinstance(id,str)
     self.render(painter,"#" + id)
     painter.end()
     return QCursor(cursorPixmap,hotX,hotY)
开发者ID:alex-r-bigelow,项目名称:compreheNGSive,代码行数:19,代码来源:mutableSvg.py

示例11: QPixmapQDatastream

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
class QPixmapQDatastream(UsesQApplication):
    '''QDataStream <<>> QPixmap'''

    def setUp(self):
        super(QPixmapQDatastream, self).setUp()
        self.source_pixmap = QPixmap(100, 100)
        self.source_pixmap.fill(Qt.red)
        self.output_pixmap = QPixmap()
        self.buffer = QByteArray()
        self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
        self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)

    def testStream(self):
        self.write_stream << self.source_pixmap

        self.read_stream >> self.output_pixmap

        image = self.output_pixmap.toImage()
        pixel = image.pixel(10,10)
        self.assertEqual(pixel, QColor(Qt.red).rgba())
        self.assertEqual(self.source_pixmap.toImage(), self.output_pixmap.toImage())
开发者ID:Hasimir,项目名称:PySide,代码行数:23,代码来源:qdatastream_gui_operators_test.py

示例12: addLayer

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
    def addLayer(self, name, visible, frozen, zValue, color, lineType, lineWeight, print_):
        """
        TOWRITE for :class:`LayerManager`.

        :param `name`: TOWRITE
        :type `name`: QString
        :param `visible`: TOWRITE
        :type `visible`: bool
        :param `frozen`: TOWRITE
        :type `frozen`: bool
        :param `zValue`: TOWRITE
        :type `zValue`: qreal
        :param `color`: TOWRITE
        :type `color`: QRgb
        :param `lineType`: TOWRITE
        :type `lineType`: QString
        :param `lineWeight`: TOWRITE
        :type `lineWeight`: QString
        :param `print_`: TOWRITE
        :type `print_`: bool
        """

        self.layerModel.insertRow(0)
        self.layerModel.setData(self.layerModel.index(0, 0), name)
        self.layerModel.setData(self.layerModel.index(0, 1), visible)
        self.layerModel.setData(self.layerModel.index(0, 2), frozen)
        self.layerModel.setData(self.layerModel.index(0, 3), zValue)

        colorPix = QPixmap(QSize(16, 16))
        colorPix.fill(QColor(color))
        self.layerModel.itemFromIndex(self.layerModel.index(0, 4)).setIcon(QIcon(colorPix))
        self.layerModel.setData(self.layerModel.index(0, 4), QColor(color))

        self.layerModel.setData(self.layerModel.index(0, 5), lineType)
        self.layerModel.setData(self.layerModel.index(0, 6), lineWeight)
        self.layerModel.setData(self.layerModel.index(0, 7), print_)
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:38,代码来源:layer_manager.py

示例13: MainWindow

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]

#.........这里部分代码省略.........
        widget = QWidget(self)
        layout = QGridLayout()
        layout.setRowStretch(0, 1)
        layout.setRowStretch(1, 0)

        topLayout = QGridLayout()
        bottomLayout = QGridLayout()

        topLayout.setColumnStretch(0, 0)
        topLayout.setColumnStretch(1, 1)

        bottomLayout.setColumnStretch(0, 0)
        bottomLayout.setColumnStretch(1, 1)

        topLayout.addWidget(self.slider, 0, 0)
        topLayout.addWidget(self.view, 0, 1)

        bottomLayout.addLayout(mapControlLayout, 0, 0)
        bottomLayout.addLayout(coordControlLayout, 0, 1)

        layout.addLayout(topLayout, 0, 0)
        layout.addLayout(bottomLayout, 1, 0)

        self.layout = layout
        widget.setLayout(layout)
        self.setCentralWidget(widget)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)

        self.view.customContextMenuRequested.connect(self.customContextMenuRequest)

    def createPixmapIcon(self):
        self.markerIcon = QPixmap(MARKER_WIDTH, MARKER_HEIGHT)
        self.markerIcon.fill(Qt.transparent)

        painter = QPainter(self.markerIcon)

        p1 = QPoint(MARKER_WIDTH / 2, MARKER_HEIGHT - 1)
        p2 = QPoint(MARKER_WIDTH / 2, MARKER_HEIGHT - 1 - MARKER_PIN_LEN)
        pen = QPen(Qt.black)
        pen.setWidth(2)
        pen.setCosmetic(True)
        painter.setPen(pen)
        painter.drawLine(p1, p2)
        ellipse = QRect(0, 0, MARKER_WIDTH - 1, MARKER_HEIGHT - 1)
        pen.setWidth(1)
        painter.setPen(pen)
        color = QColor(Qt.green)
        color.setAlpha(127)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(ellipse)

    def resizeEvent(self, event):
        self.view.setSceneRect(QRectF(QPointF(0.0, 0.0), self.view.size()))
        self.mapWidget.resize(self.view.size())

    def showEvent(self, event):
        self.view.setSceneRect(QRectF(QPointF(0.0, 0.0), self.view.size()))
        self.mapWidget.resize(self.view.size())

    def createMenus(self):
        self.popupMenu = QMenu(self)

        # Markers
        subMenuItem = QMenu(self.tr('Marker'), self)
开发者ID:AmerGit,项目名称:Examples,代码行数:70,代码来源:mapviewer.py

示例14: import

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
from PySide.QtGui import (QApplication, QGraphicsView, QGraphicsScene,
                          QMainWindow, QPixmap, QPainter)
from PySide.QtCore import Qt
import sys

if __name__ == '__main__':
    app = QApplication(sys.argv)
    scene = QGraphicsScene()
    view = QGraphicsView(scene)
    view.scale(15, 15)

    pix = QPixmap(200, 50)
    pix.fill(Qt.white)
    p = QPainter(pix)
    p.setPen(Qt.black)
    #p.setBrush(Qt.red)
    for i in range(1, 10):
        p.drawEllipse(0, 0, i, i)
        p.translate(i+5, 0)
    p.end()
    pixItem = scene.addPixmap(pix)

    win = QMainWindow()
    win.setCentralWidget(view)
    win.resize(700, 200)
    win.show()

    sys.exit(app.exec_())
开发者ID:jthacker,项目名称:arrview,代码行数:30,代码来源:ellipse_test.py

示例15: drag

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import fill [as 别名]
    def drag ( self, data, type = None, request = 'copy', image = None ):
        """ Initiates a drag operation with the specified *data*. If *type* is
            **None**, the control will try to determine the kind of data being
            dragged from the data itself. Other than **None**, the legal values
            for *type* are: 'color', 'image', 'text', 'html', 'files', 'urls'
            and 'object'.

            *Request* specifies whether the data is to be copied ('copy'),
            moved ('move') or linked ('link'), with the default request being to
            copy the data.

            *Image* specifies an ImageResource image to be used while dragging
            to provide the user with some indication of what is being dragged.
            This may not be supported with all UI back-ends. If not supported,
            the *image* value is treated as *None*. A value of *None* indicates
            that the default drag image should be used.

            The result is a string indicating the action taken by the receiver
            (if any) of the data at the completion of the drag and drop
            operation. The possible values are: 'copy', 'move', 'link' and
            'ignore'.
        """
        if type is None:
            if isinstance( data, basestring ):
                type = 'text'
            elif isinstance( data, QColor ):
                type = 'color'
            elif isinstance( data, AnImageResource ):
                type = 'image'
                data = data.image
            elif isinstance( data, SequenceTypes ):
                type = 'urls'
                data = [ QUrl( item ) for item in data ]
            else:
                type = 'object'

        mime_data = getattr( self, '_drag_%s' % type,
                             self._drag_object )( data )
        drag      = QDrag( self.control )
        drag.setMimeData( mime_data )

        # Set up the drag image (if one was specified):
        if isinstance( image, AnImageResource ):
            bitmap   = image.bitmap
            idx, idy = image.width, image.height
            ratio    = max( idx, idy ) / 128.0
            if ratio > 1.0:
                # Create a scaled version of the image if it is larger than the
                # maximum nominal size:
                sdx = int( round( idx / ratio ) )
                sdy = int( round( idy / ratio ) )
                pm  = QPixmap( sdx, sdy )
                pm.fill( QColor( 0, 0, 0, 0 ) )
                painter = painter_for( pm )
                painter.drawPixmap( 0, 0, sdx, sdy, bitmap, 0, 0, idx, idy )
                painter.end()
                bitmap, idx, idy = pm, sdx, sdy

            drag.setPixmap( bitmap )
            drag.setHotSpot( QPoint( idx / 2, idy / 2 ) )

        return RequestAction[ drag.exec_() ]
开发者ID:davidmorrill,项目名称:facets,代码行数:64,代码来源:control.py


注:本文中的PySide.QtGui.QPixmap.fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。