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


Python QPen.setCapStyle方法代码示例

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


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

示例1: paint

# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setCapStyle [as 别名]
    def paint(self, canvas, is_secondary_color=False, additional_flag=False):
        pen = QPen()

        if is_secondary_color:
            pen.setColor(self.data_singleton.secondary_color)
        else:
            pen.setColor(self.data_singleton.primary_color)

        painter = QPainter(canvas.image)
        painter.setRenderHint(QPainter.Antialiasing)
        pen.setWidth(self.data_singleton.pen_size)
        pen.setStyle(Qt.SolidLine)
        pen.setCapStyle(Qt.RoundCap)
        pen.setJoinStyle(Qt.RoundJoin)

        painter.setPen(pen)

        if is_secondary_color:
            painter.setBrush(self.data_singleton.primary_color)
        else:
            painter.setBrush(self.data_singleton.secondary_color)

        if self._start_point != self._end_point:
            painter.drawRect(QRect(self._start_point, self._end_point))

        painter.end()

        canvas.edited = True
        canvas.update()
开发者ID:gil9red,项目名称:fake-painter,代码行数:31,代码来源:rectangleinstrument.py

示例2: paintEvent

# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setCapStyle [as 别名]
 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,代码行数:36,代码来源:support.py

示例3: default_roi_pen

# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setCapStyle [as 别名]
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,代码行数:10,代码来源:settings.py

示例4: routeFinished

# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setCapStyle [as 别名]
    def routeFinished(self):

        if not self.routeReply.routes():
            return

        route = QGeoMapRouteObject(self.routeReply.routes()[0])
        routeColor = QColor(Qt.blue)
        routeColor.setAlpha(127)
        pen = QPen(routeColor)
        pen.setWidth(7)
        pen.setCosmetic(True)
        pen.setCapStyle(Qt.RoundCap)
        route.setPen(pen)
        self.mapWidget.addMapObject(route)
开发者ID:AmerGit,项目名称:Examples,代码行数:16,代码来源:mapviewer.py

示例5: BaseObject

# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setCapStyle [as 别名]
class BaseObject(QGraphicsPathItem):
    """
    Subclass of `QGraphicsPathItem`_

    TOWRITE

    """

    Type = OBJ_TYPE_BASE

    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()


    def __del__(self):
        """Class destructor."""
        qDebug("BaseObject Destructor()")

    def type(self):
        """
        TOWRITE

        :return: TOWRITE
        :rtype: int
        """
        return self.Type

    def setObjectColor(self, color):
        """
        TOWRITE

        :param `color`: TOWRITE
        :type `color`: `QColor`_
        """
        self.objPen.setColor(color)
        self.lwtPen.setColor(color)

    def setObjectColorRGB(self, rgb):
        """
        TOWRITE

        :param `rgb`: TOWRITE
        :type `rgb`: `QRgb`_
        """
        self.objPen.setColor(QColor(rgb))
        self.lwtPen.setColor(QColor(rgb))

    def setObjectLineType(self, lineType):
        """
        TOWRITE

        :param `rgb`: TOWRITE
        :type `rgb`: Qt.PenStyle
        """
        self.objPen.setStyle(lineType)
        self.lwtPen.setStyle(lineType)

    def setObjectLineWeight(self, lineWeight):
        """
        TOWRITE

        :param `lineWeight`: TOWRITE
        :type `lineWeight`: qreal
        """
        self.objPen.setWidthF(0)  # NOTE: The objPen will always be cosmetic

        if lineWeight < 0:
            if lineWeight == OBJ_LWT_BYLAYER:
                self.lwtPen.setWidthF(0.35)  # TODO: getLayerLineWeight
            elif lineWeight == OBJ_LWT_BYBLOCK:
                self.lwtPen.setWidthF(0.35)  # TODO: getBlockLineWeight
            else:
                QMessageBox.warning(0, QObject.tr("Error - Negative Lineweight"),
                                       QObject.tr("Lineweight: %f" % lineWeight))
                qDebug("Lineweight cannot be negative! Inverting sign.")
                self.lwtPen.setWidthF(-lineWeight)
        else:
#.........这里部分代码省略.........
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:103,代码来源:object_base.py

示例6: loadFile

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

#.........这里部分代码省略.........
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddEllipse(embEllipse_centerX(e), embEllipse_centerY(e), embEllipse_width(e), embEllipse_height(e), 0, False, OBJ_RUBBER_OFF)  # TODO: rotation and fill
                    curEllipseObj = curEllipseObj.next

            if p.lineObjList:
                curLineObj = p.lineObjList  # EmbLineObjectList*
                while curLineObj:
                    li = curLineObj.lineObj.line  # EmbLine
                    thisColor = curLineObj.lineObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddLine(embLine_x1(li), embLine_y1(li), embLine_x2(li), embLine_y2(li), 0, OBJ_RUBBER_OFF)  # TODO: rotation
                    curLineObj = curLineObj.next

            if p.pathObjList:
                # TODO: This is unfinished. It needs more work
                curPathObjList = p.pathObjList  # EmbPathObjectList*
                while curPathObjList:
                    pathPath = QPainterPath()
                    curPointList = curPathObjList.pathObj.pointList  # EmbPointList*
                    thisColor = curPathObjList.pathObj.color  # EmbColor
                    if curPointList:
                        pp = curPointList.point  # EmbPoint
                        pathPath.moveTo(embPoint_x(pp), -embPoint_y(pp))  # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
                        curPointList = curPointList.next

                    while curPointList:
                        pp = curPointList.point  # EmbPoint
                        pathPath.lineTo(embPoint_x(pp), -embPoint_y(pp))  # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
                        curPointList = curPointList.next

                    loadPen = QPen(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    loadPen.setWidthF(0.35)
                    loadPen.setCapStyle(Qt.RoundCap)
                    loadPen.setJoinStyle(Qt.RoundJoin)

                    obj = PathObject(0, 0, pathPath, loadPen.color().rgb())  # PathObject*
                    obj.setObjectRubberMode(OBJ_RUBBER_OFF)
                    self.gscene.addItem(obj)

                    curPathObjList = curPathObjList.next

            if p.pointObjList:
                curPointObj = p.pointObjList  # EmbPointObjectList*
                while curPointObj:
                    po = curPointObj.pointObj.point  # EmbPoint
                    thisColor = curPointObj.pointObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddPoint(embPoint_x(po), embPoint_y(po))
                    curPointObj = curPointObj.next

            if p.polygonObjList:
                curPolygonObjList = p.polygonObjList  # EmbPolygonObjectList*
                while curPolygonObjList:
                    polygonPath = QPainterPath()
                    firstPoint = False  # bool
                    startX = 0; startY = 0  # qreal
                    x = 0; y = 0  # qreal
                    curPointList = curPolygonObjList.polygonObj.pointList  # EmbPointList*
                    thisColor = curPolygonObjList.polygonObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    while curPointList:
                        pp = curPointList.point  # EmbPoint
                        x = embPoint_x(pp)
                        y = -embPoint_y(pp)  # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:70,代码来源:mdiwindow.py


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