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


Python QtGui.QPen类代码示例

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


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

示例1: init

    def init(self, parent):
        '''

        '''
        if self.control is None:
            self.control = qtLED()
            scene = QGraphicsScene()
            #             self.control.setStyleSheet("qtLED { border-style: none; }");
            #             self.control.setAutoFillBackground(True)

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
            self.control.setStyleSheet("border: 0px")
            self.control.setMaximumWidth(35)
            self.control.setMaximumHeight(35)

            x, y = 10, 10
            rad = 20
            cx = x + rad / 1.75
            cy = y + rad / 1.75

            brush = self.get_color(self.value.state, cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self.led = scene.addEllipse(x, y, rad, rad,
                                        pen=pen,
                                        brush=brush
            )

            self.control.setScene(scene)

            self.value.on_trait_change(self.update_object, 'state')
开发者ID:UManPychron,项目名称:pychron,代码行数:32,代码来源:led_editor.py

示例2: paintEvent

 def paintEvent(self, pe):
   painter = QPainter(self)
   painter.save()
   gradient = QLinearGradient()
   gradient.setStart(self._grad_start)
   gradient.setFinalStop(self._grad_end)
   gradient.setColorAt(0, QColor(230, 230, 230))
   gradient.setColorAt(1, QColor(247, 247, 247))
   brush = QBrush(gradient)
   painter.setBrush(brush)
   pen = QPen(Qt.black)
   pen.setWidth(1)
   painter.setPen(pen)
   painter.drawPath(self._painter_path)
   painter.restore()
   font = QFont()
   font.setFamily("Tahoma")
   font.setPixelSize(11)
   font.setBold(True)
   pen = QPen(Qt.darkGray)
   painter.setPen(pen)
   painter.setFont(font)
   self_rect = QRect(self.rect())
   self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
   painter.drawText(self_rect, Qt.AlignLeft, self._text)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:25,代码来源:ui_common.py

示例3: p

        def p(painter, color):
            device = painter.device()
            width, height = device.width(), device.height()
            painter.setRenderHint(QPainter.Antialiasing)
            pen = QPen()
            pen.setWidth(thickness)
            if random:
                pen.setBrush(noise_brush)
            painter.setPen(pen)
            painter.setOpacity(opacity/100)

            def getpoints(x, y):
                if angle in [0, 180]:
                    return (0, y), (width, y)
                if angle in [90, 270]:
                    return (x, 0), (x, height)
                derp = max(height, width)
                deg = math.radians(angle)
                p1 = (x - derp*math.cos(deg), y + derp * math.sin(deg))
                p2 = (x+derp*math.cos(deg), y - derp * math.sin(deg))
                return p1, p2


            for pos in range(spacing+thickness, max(height, width), spacing+thickness):
                x = pos if angle < 90 else width-pos
                y = pos
                (x1, y1), (x2, y2) = getpoints(x, y)
                painter.drawLine(x1, y1, x2, y2)
            return
开发者ID:d42,项目名称:Fourierism,代码行数:29,代码来源:noise_dialog.py

示例4: __init__

    def __init__(self, parent=None):
        """
        Default class constructor.

        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QGraphicsItem`_
        """
        super(BaseObject, self).__init__(parent)

        qDebug("BaseObject Constructor()")

        self.objPen = QPen()        # QPen objPen;
        self.lwtPen = QPen()        # QPen lwtPen;
        self.objLine = QLineF()     # QLineF objLine;
        self.objRubberMode = int()  # int objRubberMode;
        self.objRubberPoints = {}   # QHash<QString, QPointF> objRubberPoints;
        self.objRubberTexts = {}    # QHash<QString, QString> objRubberTexts;
        self.objID = int()          # qint64 objID;

        self.objPen.setCapStyle(Qt.RoundCap)
        self.objPen.setJoinStyle(Qt.RoundJoin)
        self.lwtPen.setCapStyle(Qt.RoundCap)
        self.lwtPen.setJoinStyle(Qt.RoundJoin)

        self.objID = QDateTime.currentMSecsSinceEpoch()
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:25,代码来源:object_base.py

示例5: __init__

    def __init__(self, s, parent=None):
        """
        Default class constructor.

        :param `s`: TOWRITE
        :type `s`: QRubberBand.Shape
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(SelectBox, self).__init__(s, parent)

        # private
        self._leftBrushColor = QColor()
        self._rightBrushColor = QColor()
        self._leftPenColor = QColor()
        self._rightPenColor = QColor()
        self._alpha = 255  # quint8  #: TODO: what is the initial int?

        self._dirBrush = QBrush()
        self._leftBrush = QBrush()
        self._rightBrush = QBrush()

        self._dirPen = QPen()
        self._leftPen = QPen()
        self._rightPen = QPen()

        self._boxDir = False  #: TODO: is this initial bool value right?

        # Default values
        self.setColors(QColor(Qt.darkGreen), QColor(Qt.green), QColor(Qt.darkBlue), QColor(Qt.blue), 32)
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:30,代码来源:selectbox.py

示例6: selectionLayer

class selectionLayer(layer):
    def __init__(self, size, dynamic, controller, prototypeLine, opaqueBack = False):
        layer.__init__(self,size,dynamic)
        self.controller = controller
        self.points = set()
        if opaqueBack:
            self.backgroundColor = Qt.white
        else:
            self.backgroundColor = Qt.transparent
        
        lineColor = QColor()
        lineColor.setNamedColor(prototypeLine.getAttribute('stroke'))
        lineColor.setAlphaF(float(prototypeLine.getAttribute('stroke-opacity')))
        self.pen = QPen(lineColor)
        
        self.pen.setWidthF(prototypeLine.getAttribute('stroke-width'))
    
    def handleFrame(self, event, signals):
        return signals
    
    def refreshLines(self, points):
        self.points = points
        self.setDirty()
    
    def draw(self,painter):
        if len(self.points) >= self.controller.app.resolution_threshold:
            return
        pointList = list(self.points)
        self.image.fill(self.backgroundColor)
        painter.setPen(self.pen)
        painter.setRenderHint(QPainter.Antialiasing)
        lastA = self.controller.axisOrder[0]
        lastValues = self.controller.vData.getData(pointList,lastA)
        lastX = self.controller.axes[lastA].visAxis.axisLine.left()
        for a in self.controller.axisOrder[1:]:
            if not self.controller.axes[a].visible:
                continue
            values = self.controller.vData.getData(pointList,a)
            x = self.controller.axes[a].visAxis.axisLine.left()
            for y0,y1 in zip(lastValues,values):
                y0 = self.controller.axes[lastA].dataToScreen(y0)
                y1 = self.controller.axes[a].dataToScreen(y1)
                if len(y0) > len(y1):
                    if len(y1) > 1:
                        raise Exception("Mismatched number of values between attributes: %s %s" % (y0,y1))
                    else:
                        for y00 in y0:
                            painter.drawLine(lastX,y00,x,y1[0])
                elif len(y1) > len(y0):
                    if len(y0) > 1:
                        raise Exception("Mismatched number of values between attributes: %s %s" % (y0,y1))
                    else:
                        for y11 in y1:
                            painter.drawLine(lastX,y0[0],x,y11)
                else:
                    for i,y00 in enumerate(y0):
                        painter.drawLine(lastX,y00,x,y1[i])
            lastA = a
            lastValues = values
            lastX = x
开发者ID:alex-r-bigelow,项目名称:compreheNGSive,代码行数:60,代码来源:parallelCoordinateWidget.py

示例7: setChosen

 def setChosen(self, ch):
     self.chosen = ch
     if ch:
         redPen = QPen(Qt.red)
         redPen.setWidth(2)
         self.setPen(redPen)
     else:
         self.setPen(QPen())
开发者ID:Odingod,项目名称:Vuoropohjainen-peli,代码行数:8,代码来源:Hexagon.py

示例8: paintEvent

 def paintEvent(self, pe):
   # make an arrow polygon right in the middle
   painter = QPainter(self)
   painter.setPen(Qt.NoPen)
   # draw the background transparent rect
   painter.save()
   painter.setOpacity(self.BACKGROUND_OPACITY)
   # get the rectangle coordinates it should extend over the whole width with only a portion at the center
   painter.setBrush(Qt.black)
   empty_space_percent = 1 - self.BACKROUND_HEIGHT_PERCENT
   rect_top = empty_space_percent / 2 * self.height()
   rect_height = self.BACKROUND_HEIGHT_PERCENT * self.height()
   painter.drawRect(0, rect_top, self.width(), rect_height)
   painter.restore()
   painter.setRenderHint(QPainter.Antialiasing)
   pen = QPen()
   pen.setWidth(self.ARROW_LINE_WIDTH)
   pen.setCapStyle(Qt.RoundCap)
   if self._mouse_inside:
     pen.setColor(self._hover_color)
   else:
     pen.setColor(self._normal_color)
   # get the arrow coords
   painter.setPen(pen)
   self_center = QPointF(self.width() / 2, self.height() / 2) # use this as the arrow tip for now
   if self._direction == self.LEFT:
     h_shift = self._arrow_width
   elif self._direction == self.RIGHT:
     h_shift = - self._arrow_width
   v_shift = self._arrow_height / 2
   top_point = self_center + QPointF(h_shift, - v_shift)
   bottom_point = self_center + QPointF(h_shift, v_shift)
   painter.drawLine(top_point, self_center)
   painter.drawLine(self_center, bottom_point)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:34,代码来源:support.py

示例9: drawPolyline

    def drawPolyline(self):
        path = [mark.coordinate() for mark in self.markerObjects]

        pen = QPen(Qt.white)
        pen.setWidth(2)
        pen.setCosmetic(True)
        polyline = QGeoMapPolylineObject()
        polyline.setPen(pen)
        polyline.setPath(path)

        self.mapWidget.addMapObject(polyline)
开发者ID:AmerGit,项目名称:Examples,代码行数:11,代码来源:mapviewer.py

示例10: default_roi_pen

def default_roi_pen(dashed=True,color=Qt.green):
    pen = QPen()
    if dashed:
        pen.setStyle(Qt.DashLine)
    pen.setBrush(color)
    pen.setCapStyle(Qt.RoundCap)
    pen.setJoinStyle(Qt.RoundJoin)
    return pen
开发者ID:jthacker,项目名称:arrview,代码行数:8,代码来源:settings.py

示例11: realRender

    def realRender(self, painter, renderPath):  # TODO/PORT: Still needs work.
        """
        TOWRITE

        :param `painter`: TOWRITE
        :type `painter`: `QPainter`_
        :param `renderPath`: TOWRITE
        :type `renderPath`: `QPainterPath`_
        """
        color1 = self.objectColor()  #QColor  # lighter color
        color2 = color1.darker(150)  #QColor  # darker color

        # If we have a dark color, lighten it
        darkness = color1.lightness() #int
        threshold = 32 #int   #TODO: This number may need adjusted or maybe just add it to settings.
        if darkness < threshold:
            color2 = color1
            if not darkness:
                color1 = QColor(threshold, threshold, threshold)  # lighter() does not affect pure black
            else :
                color1 = color2.lighter(100 + threshold)

        count = renderPath.elementCount()  # int
        for i in range(0, count - 1):  # for(int i = 0; i < count-1; ++i);

            elem = renderPath.elementAt(i)      # QPainterPath::Element
            next = renderPath.elementAt(i + 1)  # QPainterPath::Element

            if next.isMoveTo():
                continue

            elemPath = QPainterPath()
            elemPath.moveTo(elem.x, elem.y)
            elemPath.lineTo(next.x, next.y)

            renderPen = QPen(QColor(0, 0, 0, 0))
            renderPen.setWidthF(0)
            painter.setPen(renderPen)
            stroker = QPainterPathStroker()
            stroker.setWidth(0.35)
            stroker.setCapStyle(Qt.RoundCap)
            stroker.setJoinStyle(Qt.RoundJoin)
            realPath = stroker.createStroke(elemPath)  # QPainterPath
            painter.drawPath(realPath)

            grad = QLinearGradient(elemPath.pointAtPercent(0.5), elemPath.pointAtPercent(0.0))
            grad.setColorAt(0, color1)
            grad.setColorAt(1, color2)
            grad.setSpread(QGradient.ReflectSpread)

            painter.fillPath(realPath, QBrush(grad))
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:51,代码来源:object_base.py

示例12: paintEvent

 def paintEvent(self, pe):
   if not self._hover_rect:
     super(TrackerWebView, self).paintEvent(pe)
   else:
     super(TrackerWebView, self).paintEvent(pe)
     hover_rect = self._hover_rect
     self._fixRectForScroll(hover_rect)
     painter = QPainter(self)
     painter.save()
     pen = QPen(Qt.red)
     pen.setWidth(2)
     painter.setPen(pen)
     painter.drawRect(hover_rect)
     painter.restore()
     # draw green rects around the similar elements
     pen = QPen()
     pen.setWidth(2)
     for field_info in self._fields_info:
       painter.save()
       web_elements = field_info.web_elements
       color = field_info.color
       pen.setColor(color)
       painter.setPen(pen)
       for elem in web_elements:
         elem_rect = elem.absoluteGeometry()
         painter.drawRoundedRect(self._fixRectForScroll(elem_rect), 2, 2)
       painter.restore()
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:27,代码来源:browser.py

示例13: draw

    def draw(self, painter, offset, draw_mode=DRAW_MODE_NORMAL):

        if draw_mode != Bin.DRAW_MODE_RELEASE:
            # Рисуем контур контейнера
            pen = QPen()
            pen.setStyle(Qt.DashLine)
            painter.setPen(pen)
            # painter.drawRect(self.origin.x, self.origin.y, self.size.width, self.size.height)
            painter.drawRect(offset.x, offset.y, self.size.width, self.size.height)

        for image in self.images:
            # Rect(rect.origin + self.origin, rect.size, rect.pen).draw(painter=painter)
            # image.draw(painter=painter, offset=self.origin)
            image.draw(painter=painter, offset=offset)
开发者ID:Ingener74,项目名称:Small-Screwdriver,代码行数:14,代码来源:Bin.py

示例14: drawPolygon

    def drawPolygon(self):
        path = [mark.coordinate() for mark in self.markerObjects]

        pen = QPen(Qt.white)
        pen.setWidth(2)
        pen.setCosmetic(True)
        polygon = QGeoMapPolygonObject()
        polygon.setPen(pen)
        fill = QColor(Qt.black)
        fill.setAlpha(65)
        polygon.setBrush(QBrush(fill))
        polygon.setPath(path)

        self.mapWidget.addMapObject(polygon)
开发者ID:AmerGit,项目名称:Examples,代码行数:14,代码来源:mapviewer.py

示例15: drawRect

    def drawRect(self):
        if len(self.markerObjects) < 2:
            return

        p1, p2 = self.markerObjects[:2]

        pen = QPen(Qt.white)
        pen.setWidth(2)
        pen.setCosmetic(True)
        fill = QColor(Qt.black)
        fill.setAlpha(65)
        rectangle = QGeoMapRectangleObject(p1.coordinate(), p2.coordinate())
        rectangle.setPen(pen)
        rectangle.setBrush(QBrush(fill))
        self.mapWidget.addMapObject(rectangle)
开发者ID:AmerGit,项目名称:Examples,代码行数:15,代码来源:mapviewer.py


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