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


Python QtGui.QPainter方法代码示例

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


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

示例1: getHighlightedObject

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def getHighlightedObject(self, qp):
        # These variables we want to fill
        self.highlightObjs = []
        self.highlightObjLabel = None

        # Without labels we cannot do so
        if not self.annotation:
            return

        # If available set the selected objects
        highlightObjIds = self.selObjs
        # If not available but the polygon is empty or closed, its the mouse object
        if not highlightObjIds and (self.drawPoly.isEmpty() or self.drawPolyClosed) and self.mouseObj>=0 and not self.mouseOutsideImage:
            highlightObjIds = [self.mouseObj]
        # Get the actual object that is highlighted
        if highlightObjIds:
            self.highlightObjs = [ self.annotation.objects[i] for i in highlightObjIds ]
        # Set the highlight object label if appropriate
        if self.config.highlight:
            self.highlightObjLabel = self.config.highlightLabelSelection
        elif len(highlightObjIds) == 1 and self.config.correctionMode:
            self.highlightObjLabel = self.annotation.objects[highlightObjIds[-1]].label

    # Draw the image in the given QPainter qp 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:26,代码来源:cityscapesLabelTool.py

示例2: getHighlightedObject

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def getHighlightedObject(self, qp):
        # This variable we want to fill
        self.highlightObj = None

        # Without labels we cannot do so
        if not self.annotation:
            return

        # If available its the selected object
        highlightObjId = -1
        # If not available but the polygon is empty or closed, its the mouse object
        if highlightObjId < 0 and not self.mouseOutsideImage:
            highlightObjId = self.mouseObj
        # Get the actual object that is highlighted
        if highlightObjId >= 0:
            self.highlightObj = self.annotation.objects[highlightObjId]
            self.highlightObjLabel = self.annotation.objects[highlightObjId].label

    # Draw the image in the given QPainter qp 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:21,代码来源:cityscapesViewer.py

示例3: drawDisp

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def drawDisp( self , qp ):
        if not self.dispOverlay:
            return

        # Save QPainter settings to stack
        qp.save()
        # Define transparency
        qp.setOpacity(self.transp)
        # Draw the overlay image
        qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay)
        # Restore settings
        qp.restore()

        return self.dispOverlay



    #############################
    ## Mouse/keyboard events
    #############################

    # Mouse moved
    # Need to save the mouse position
    # Need to drag a polygon point
    # Need to update the mouse selected object 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:27,代码来源:cityscapesViewer.py

示例4: drawDisp

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def drawDisp( self , qp ):
        if not self.dispOverlay:
            return 

        # Save QPainter settings to stack
        qp.save()
        # Define transparency
        qp.setOpacity(self.transp)
        # Draw the overlay image
        qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay)
        # Restore settings
        qp.restore()

        return self.dispOverlay



    #############################
    ## Mouse/keyboard events
    #############################

    # Mouse moved
    # Need to save the mouse position
    # Need to drag a polygon point
    # Need to update the mouse selected object 
开发者ID:renmengye,项目名称:rec-attend-public,代码行数:27,代码来源:cityscapesViewer.py

示例5: registerCmap

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def registerCmap(self):
        """ Add matplotlib cmaps to the GradientEditors context menu"""
        self.gradientEditorItem.menu.addSeparator()
        savedLength = self.gradientEditorItem.length
        self.gradientEditorItem.length = 100
        
        
        for name in self.mplColorMaps:
            px = QPixmap(100, 15)
            p = QPainter(px)
            self.gradientEditorItem.restoreState(self.mplColorMaps[name])
            grad = self.gradientEditorItem.getGradient()
            brush = QBrush(grad)
            p.fillRect(QtCore.QRect(0, 0, 100, 15), brush)
            p.end()
            label = QLabel()
            label.setPixmap(px)
            label.setContentsMargins(1, 1, 1, 1)
            act =QWidgetAction(self.gradientEditorItem)
            act.setDefaultWidget(label)
            act.triggered.connect(self.cmapClicked)
            act.name = name
            self.gradientEditorItem.menu.addAction(act)
        self.gradientEditorItem.length = savedLength 
开发者ID:qkitgroup,项目名称:qkit,代码行数:26,代码来源:PlotWindow.py

示例6: generatePicture

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='w', width=0.4))  # 0.4 means w*2
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
            p.end() 
开发者ID:sunshinelover,项目名称:chanlun,代码行数:18,代码来源:demoUi.py

示例7: mouseMoveEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def mouseMoveEvent(self, e):
        if e.buttons() == QtCore.Qt.LeftButton:

            mimeData = QtCore.QMimeData()
            mimeData.setText('%d,%d' % (e.x(), e.y()))

            # show the ghost image while dragging
            pixmap = QtGui.QPixmap.grabWidget(self)
            painter = QtGui.QPainter(pixmap)
            painter.fillRect(pixmap.rect(), QtGui.QColor(0, 0, 0, 127))
            painter.end()

            drag = QtGui.QDrag(self)
            drag.setMimeData(mimeData)
            drag.setPixmap(pixmap)
            drag.setHotSpot(e.pos())

            drag.exec_(QtCore.Qt.MoveAction) 
开发者ID:brendan-w,项目名称:pihud,代码行数:20,代码来源:Widget.py

示例8: generatePicture

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='r', width=0.4))  # 0.4 means w*2
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
            p.end() 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:18,代码来源:uiBasicWidget.py

示例9: paintEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHints(QtGui.QPainter.Antialiasing)

        painter.fillRect(QtCore.QRectF(50, 50, 200, 200), QtGui.QBrush(QtGui.QColor(QtGui.QColor(110, 110, 110))))
        painter.fillRect(QtCore.QRectF(50, 50, 200, 200), QtGui.QBrush(QtCore.Qt.CrossPattern))

        painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.lightGray), 2, QtCore.Qt.SolidLine))
        path = QtGui.QPainterPath()
        path.moveTo(50, 250)
        path.cubicTo(self.points[0][0], self.points[0][1], self.points[1][0], self.points[1][1], 250, 50)
        painter.drawPath(path)

        painter.setBrush(QtGui.QBrush(QtGui.QColor(QtCore.Qt.darkCyan)))
        painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.lightGray), 1))


        #for x, y in pts:
        painter.drawEllipse(QtCore.QRectF(self.points[0][0] - 4, self.points[0][1] - 4, 8, 8))
        painter.drawEllipse(QtCore.QRectF(self.points[1][0] - 4, self.points[1][1] - 4, 8, 8))
        painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.white), 1))
        label1 = "("+ str((self.points[0][0] - 50)/2) + "," + str(100 - ((self.points[0][1] -50)/2)) + ")"
        painter.drawText(self.points[0][0] -25, self.points[0][1] + 18, QtCore.QString(label1))
        label2 = "("+ str((self.points[1][0] - 50)/2) + "," + str(100 - ((self.points[1][1] -50)/2)) + ")"
        painter.drawText(self.points[1][0] -25, self.points[1][1] + 18, QtCore.QString(label2)) 
开发者ID:tb2097,项目名称:wacom-gui,代码行数:27,代码来源:pressure.py

示例10: paintEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def paintEvent(self, event):
        # Create a QPainter that can perform draw actions within a widget or image
        qp = QtGui.QPainter()
        # Begin drawing in the application widget
        qp.begin(self)
        # Update scale
        self.updateScale(qp)
        # Determine the object ID to highlight
        self.getHighlightedObject(qp)
        # Draw the image first
        self.drawImage(qp)
        # Draw the labels on top
        overlay = self.drawLabels(qp)
        # Draw the user drawn polygon
        self.drawDrawPoly(qp)
        self.drawDrawRect(qp)
        # Draw the label name next to the mouse
        self.drawLabelAtMouse(qp)
        # Draw the zoom
        # self.drawZoom(qp, overlay)
        self.drawZoom(qp,None)

        # Thats all drawing
        qp.end()

        # Forward the paint event
        QtGui.QMainWindow.paintEvent(self,event)

    # Update the scaling 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:31,代码来源:cityscapesLabelTool.py

示例11: getPolygon

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def getPolygon(self, obj):
        poly = QtGui.QPolygonF()
        for pt in obj.polygon:
            point = QtCore.QPointF(pt.x,pt.y)
            poly.append( point )
        return poly

    # Draw the labels in the given QPainter qp
    # optionally provide a list of labels to ignore 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:11,代码来源:cityscapesLabelTool.py

示例12: ptClosesPoly

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def ptClosesPoly(self):
        if self.drawPoly.isEmpty():
            return False
        if self.mousePosScaled is None:
            return False
        closestPt = self.getClosestPoint( self.drawPoly, self.mousePosScaled )
        return closestPt==(0,0)

    # Draw a point using the given QPainter qp
    # If its the first point in a polygon its drawn in green
    # if not in red
    # Also the radius might be increased 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:14,代码来源:cityscapesLabelTool.py

示例13: paintEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def paintEvent(self, event):
        qp = QtGui.QPainter()
        qp.begin(self)
        self.draw_memory(event, qp)
        qp.end() 
开发者ID:plasma-disassembler,项目名称:plasma,代码行数:7,代码来源:memmap.py

示例14: get_icon

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def get_icon(icon, size=24):
    """get svg icon from icon resources folder as a pixel map
    """
    img = get_icon_path("{}.svg".format(icon))
    svg_renderer = QtSvg.QSvgRenderer(img)
    image = QtGui.QImage(size, size, QtGui.QImage.Format_ARGB32)
    # Set the ARGB to 0 to prevent rendering artifacts
    image.fill(0x00000000)
    svg_renderer.render(QtGui.QPainter(image))
    pixmap = QtGui.QPixmap.fromImage(image)

    return pixmap 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:14,代码来源:pyqt.py

示例15: drawModeBox

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPainter [as 别名]
def drawModeBox(self, qp, xy, col, txt):
        #qp = QtGui.QPainter()
        qp.save()
        qp.translate(xy)
        qp.setBrush(col.dark())
        qp.setPen(QPen(col, 0.5, Qt.SolidLine))
        qp.setFont(QFont('Monospace', 14, QFont.Monospace))
        rh = 11
        rw = 20
        r=QRectF(-rw,-rh, 2*rw, 2*rh)
        qp.drawRect(r)
        qp.drawText(r, Qt.AlignCenter, txt)
        qp.restore() 
开发者ID:omwdunkley,项目名称:crazyflieROS,代码行数:15,代码来源:ai.py


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