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


Python QtGui.QPen方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [as 别名]
def __init__(self, qwtPlot, scale=None, hasGrid=True):
    self.__plot__ = qwtPlot
    if hasGrid:
      self.__curveCpuPlotGrid= Qwt.QwtPlotGrid()
      self.__curveCpuPlotGrid.setMajPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine))
      self.__curveCpuPlotGrid.setMinPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine))
      self.__curveCpuPlotGrid.enableXMin(True)
      self.__curveCpuPlotGrid.attach(self.__plot__)  
    self.__plot__.setCanvasBackground(QtGui.QColor(0,0,0))
    self.__plot__.enableAxis(0, False )
    self.__plot__.enableAxis(2, False )
    if scale is None:
      #self.__plot__.setAxisScale(0,0,100,20)    
      pass
    else:
      self.__plot__.setAxisScale(0, scale.min, scale.max, (scale.max - scale.min) / 10.0) 
开发者ID:wolfc01,项目名称:procexp,代码行数:18,代码来源:__init__.py

示例2: paintEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [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

示例3: drawModeBox

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [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

示例4: draw_predictions

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [as 别名]
def draw_predictions(file_path, predictions, class_index,
                     score_low, score_high):
    img = QtGui.QImage(file_path)
    painter = QtGui.QPainter(img)
    for i, pred in enumerate(predictions):
        if class_index > 0 and pred.class_index != class_index: continue
        if pred.score < score_low or pred.score > score_high: continue
        class_name = CLASS_NAMES[pred.class_index]
        x1, y1, x2, y2 = map(int, pred.bbox)
        # bbox
        painter.setPen(QtGui.QPen(PRESET_COLORS[pred.class_index], 10.0))
        # painter.setPen(QtGui.QPen(QtGui.QColor(0, 116, 217), 10.0))
        painter.setBrush(QtGui.QBrush())
        painter.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1)
        # label background rect
        painter.setPen(QtGui.QPen(PRESET_COLORS[pred.class_index], 2.0))
        painter.setBrush(QtGui.QBrush(PRESET_COLORS[pred.class_index]))
        # painter.setPen(QtGui.QPen(QtGui.QColor(0, 116, 217), 2.0))
        # painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 116, 217)))
        if class_index > 0:
            painter.drawRect(x1, y1, min(x2 - x1 + 1, 100), 30)
        else:
            painter.drawRect(x1, y1, min(x2 - x1 + 1, 200), 30)
        # label text
        painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255)))
        painter.setBrush(QtGui.QBrush())
        painter.setFont(QtGui.QFont('Arial', 20, QtGui.QFont.Bold))
        if class_index > 0:
            painter.drawText(x1 + 4, y1 + 24, '{:.2f}'.format(pred.score))
        else:
            painter.drawText(x1 + 4, y1 + 24,
                             '{} {:.2f}'.format(class_name, pred.score))
    return img 
开发者ID:myfavouritekk,项目名称:TPN,代码行数:35,代码来源:show_submission.py

示例5: tabletEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [as 别名]
def tabletEvent(self, event):
        senId = ""
        if self.sensor == "stylus" :
            senId = QtGui.QTabletEvent.Pen
        elif self.sensor == "eraser":
            senId = QtGui.QTabletEvent.Eraser
        elif self.sensor == "cursor":
            senId = QtGui.QTabletEvent.Cursor
        if event.pointerType() == senId:
            curpressure = event.pressure()
            if curpressure < 0:
                curpressure += 1
            amp = int(curpressure * 50)
            color = (1 - amp/50.0) * 255
            pen = QtGui.QPen(QtGui.QColor(color,color,color,0))

            radial = QtGui.QRadialGradient(QtCore.QPointF(event.x(),event.y()),amp,QtCore.QPointF(event.xTilt() * amp/50 ,event.yTilt() * amp))
            radial.setColorAt(0,QtGui.QColor(color,color,color,255))
            radial.setColorAt(1,QtGui.QColor(color,color,color,0))
            brush = QtGui.QBrush(radial)
            if(amp >= 1):
                if len(self.scene.items()) >= 50:
                    render = QtGui.QPixmap(250,250)
                    painter = QtGui.QPainter(render)
                    rect = QtCore.QRectF(0,0,250,250)
                    self.scene.render(painter,rect,rect,QtCore.Qt.KeepAspectRatio)
                    self.scene.clear()
                    self.scene.addPixmap(render)
                    painter.end()
                self.scene.addEllipse(event.x() - amp, event.y() -amp, amp, amp, pen, brush)
            self.info.updateInfo(event.xTilt(),event.yTilt(),amp) 
开发者ID:tb2097,项目名称:wacom-gui,代码行数:33,代码来源:pressure.py

示例6: drawDrawRect

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [as 别名]
def drawDrawRect(self, qp):

        qp.save()
        qp.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush))
        qp.setFont(QtGui.QFont('QFont::AnyStyle', 14))
        thickPen = QtGui.QPen()
        qp.setPen(thickPen)

        for c in self.corrections:
            rect = copy.deepcopy(c.bbox)

            width = rect.width()
            height = rect.height()
            rect.setX(c.bbox.x() * self.scale + self.xoff)
            rect.setY(c.bbox.y() * self.scale + self.yoff)

            rect.setWidth(width * self.scale)
            rect.setHeight(height * self.scale)

            if c.selected:
                thickPen.setColor(QtGui.QColor(0,0,0))
                if c.type == CorrectionBox.types.QUESTION:
                    descr = "QUESTION"
                elif c.type == CorrectionBox.types.RESOLVED:
                    descr = "FIXED"
                else:
                    descr = "ERROR"
                qp.setPen(thickPen)
                qp.drawText(QtCore.QPoint( self.xoff, self.yoff + self.h + 20 ),
                                           "(%s: %s)" % (descr, c.annotation))
                pen_width = 6
            else:
                pen_width = 3

            colour = c.get_colour()
            thickPen.setColor(colour)
            thickPen.setWidth(pen_width)
            qp.setPen(thickPen)
            qp.drawRect(rect)

        if self.in_progress_bbox is not None:
            rect = copy.deepcopy(self.in_progress_bbox)
            width = rect.width()
            height = rect.height()
            rect.setX(self.in_progress_bbox.x() * self.scale + self.xoff)
            rect.setY(self.in_progress_bbox.y() * self.scale + self.yoff)

            rect.setWidth(width * self.scale)
            rect.setHeight(height * self.scale)

            thickPen.setColor(QtGui.QColor(255,0,0))
            thickPen.setWidth(3)
            qp.setPen(thickPen)
            qp.drawRect(rect)


        qp.restore()

    # Draw the polygon that is drawn and edited by the user
    # Usually the polygon must be rescaled properly. However when drawing
    # The polygon within the zoom, this is not needed. Therefore the option transform. 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:63,代码来源:cityscapesLabelTool.py

示例7: drawMotors

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [as 别名]
def drawMotors(self, qp):
        # TODO Check if motor update is recent
        if (self.motors[0]<0):
            return

        defaultCol = QColor(0,255,0, 200)

        #qp = QtGui.QPainter()
        qp.resetTransform()
        w = self.width()
        h = self.height()


        maxSize = min(w,h)*0.175
        minSize = maxSize/10.
        qp.translate(w- maxSize, h-maxSize)
        qp.translate(-12,-12)
        qp.rotate(45)



        lighter = defaultCol
        lighter.setAlphaF(0.1)
        qp.setBrush(lighter.dark())
        qp.setPen(lighter)

        # Draw background circle
        qp.drawEllipse(QPointF(0,0),maxSize,maxSize)

        # Draw Thrust Average
        spread = 2
        avg = sum(self.motors)/len(self.motors) /100. * (maxSize-minSize) + minSize
        lighter.setAlphaF(0.5)
        qp.setPen(lighter.lighter())
        qp.setBrush(QColor(0,0,0,0))
        qp.drawEllipse(QPointF(0,0),avg, avg)

        qp.setBrush(lighter.dark())
        lighter.setAlphaF(0.2)
        qp.setPen(lighter)

        qp.setPen(QPen(defaultCol))
        qp.setBrush(QBrush(defaultCol.dark()))

        for i in range(4):
            m = self.motors[i]*2/100. * (maxSize-minSize) + minSize
            qp.drawPie(QRectF(spread-m/2., spread-m/2., m, m), 0, -90*16)
            qp.rotate(-90) 
开发者ID:omwdunkley,项目名称:crazyflieROS,代码行数:50,代码来源:ai.py

示例8: __init__

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QPen [as 别名]
def __init__(self, parent):
        #初始化
        self.parent = parent
        self.paint = QtGui.QPainter()
        self.paint.begin(self.parent)

        #设置抗锯齿
        self.paint.setRenderHint(QtGui.QPainter.Antialiasing)

        #度量尺对象
        self.metrics = self.paint.fontMetrics()

        #设置字体库
        self.fonts = dict()
        self.fonts['default'] = QtGui.QFont('Serif', 9, QtGui.QFont.Light)
        self.fonts['yahei_14_bold']= QtGui.QFont('Serif',12,QtGui.QFont.Bold)
        self.fonts['yahei_14']= QtGui.QFont('Serif',12,QtGui.QFont.Light)
        self.setFont('default')

        #设置笔刷样式库
        self.pens = dict()
        #红色 1px粗  1px点 2px距 线条
        self.pens['red_1px_dashline'] = QtGui.QPen( QtCore.Qt.red, 1, QtCore.Qt.DashLine) 
        self.pens['red_1px_dashline'].setDashPattern([1,2])
        #红色 1px粗 实线条
        self.pens['red'] = QtGui.QPen( QtCore.Qt.red, 1, QtCore.Qt.SolidLine)
        #红色 2px粗 实线条
        self.pens['red_2px'] = QtGui.QPen( QtCore.Qt.red, 2, QtCore.Qt.SolidLine)
        #红色 3px粗 实线条
        self.pens['red_3px'] = QtGui.QPen( QtCore.Qt.red, 3, QtCore.Qt.SolidLine)
        #黄色 1px粗 实线条
        self.pens['yellow'] = QtGui.QPen( QtCore.Qt.yellow, 1, QtCore.Qt.SolidLine)
        #白色 1px粗 实线条
        self.pens['white'] = QtGui.QPen( QtCore.Qt.white , 1, QtCore.Qt.SolidLine)
        #灰色 1px粗 实线条
        self.pens['gray'] = QtGui.QPen( QtCore.Qt.gray, 1, QtCore.Qt.SolidLine)
        #绿色 1px粗 实线条
        self.pens['green'] = QtGui.QPen( QtCore.Qt.green, 1, QtCore.Qt.SolidLine)
        #绿色 2px粗 实线条
        self.pens['green_2px'] = QtGui.QPen( QtCore.Qt.green, 2, QtCore.Qt.SolidLine)
        #亮蓝 1px粗  1px点 2px距 线条
        self.pens['cyan_1px_dashline'] = QtGui.QPen( QtCore.Qt.cyan, 1, QtCore.Qt.DashLine) 
        self.pens['cyan_1px_dashline'].setDashPattern([3,2])
        
        #获得窗口的长和宽
        size = self.parent.size()
        self.w = size.width()
        self.h = size.height()

        #设置grid的上下左右补丁边距
        self.grid_padding_left   = 45  #左侧补丁边距
        self.grid_padding_right  = 245 #右侧补丁边距
        self.grid_padding_top    = 25  #顶部补丁边距
        self.grid_padding_bottom = 17  #底部补丁边距

        #开始绘制
        self.start_paint()
        self.paint.end()   #结束 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:60,代码来源:drawMK.py


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