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


Python QLinearGradient.setSpread方法代码示例

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


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

示例1: drawLineSection

# 需要导入模块: from PyQt4.QtGui import QLinearGradient [as 别名]
# 或者: from PyQt4.QtGui.QLinearGradient import setSpread [as 别名]
 def drawLineSection(self, painter, firstP, secondP, firstCorner, secondCorner):
     direction = self.getPointToPointDirection(firstP, secondP)
     
     thickness = self.CONNECTION_THICKNESS * self.zoomFactor()
     halfthick = thickness / 2
     cornerRoundness = halfthick ** 0.5
     cornerOffset = halfthick * cornerRoundness * (4 * self.zoomFactor()**2)
     innerCorner = halfthick * (cornerRoundness + 1)
     outerCorner = halfthick * (cornerRoundness - 1)
     
     rect = self.getRectBetweenTwoPoints(firstP, secondP, firstCorner, secondCorner)
         # Paint witch color gradient (PyQt4)
     if direction == self.ConnectionDirection.LEFT:     # horizontal, negative
         brush = QLinearGradient(rect.x(), rect.y(), rect.x(), rect.y() + halfthick)
     elif direction == self.ConnectionDirection.RIGHT:  # horizontal, positive
         brush = QLinearGradient(rect.x(), rect.y(), rect.x(), rect.y() + halfthick)
     elif direction == self.ConnectionDirection.UP:     # vertical, negative
         brush = QLinearGradient(rect.x(), rect.y(), rect.x() + halfthick, rect.y())
     elif direction == self.ConnectionDirection.DOWN:   # vertical, positive
         brush = QLinearGradient(rect.x(), rect.y(), rect.x() + halfthick, rect.y())
     
     brush.setSpread(QLinearGradient.ReflectSpread)
     brush.setColorAt(0, self.FILL_COLOR1)
     brush.setColorAt(1, self.FILL_COLOR2)
     painter.setBrush(brush)
     
     painter.drawRect(rect)
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:29,代码来源:PortConnection.py

示例2: _gen_striped_gradient

# 需要导入模块: from PyQt4.QtGui import QLinearGradient [as 别名]
# 或者: from PyQt4.QtGui.QLinearGradient import setSpread [as 别名]
def _gen_striped_gradient(basecolor):
    """Just generate a standard gradient, for use as a background"""
    g = QLinearGradient()
    g.setSpread(g.ReflectSpread)
    g.setStart(0,0)
    g.setFinalStop(2, 2)
    g.setColorAt(0.0, QColor(basecolor))
    g.setColorAt(0.35, QColor(0,0,0,0))
    g.setColorAt(0.75, QColor(0,0,0,0))
    g.setColorAt(1.0, QColor(basecolor))
    return g
开发者ID:mnunberg,项目名称:yobot,代码行数:13,代码来源:chatwindow.py

示例3: drawSection

# 需要导入模块: from PyQt4.QtGui import QLinearGradient [as 别名]
# 或者: from PyQt4.QtGui.QLinearGradient import setSpread [as 别名]
    def drawSection(self, painter, sectionIndex):
        """ This is going to replace drawLineSection
        """
        firstP = self.mapFromParent(self._route[sectionIndex])
        secondP = self.mapFromParent(self._route[sectionIndex +1])
        direction = self.getPointToPointDirection(firstP, secondP)
        
        if self.CONNECTION_TYPE!="ORTHOGONAL" or direction == self.ConnectionDirection.UNDEFINED:
            self.drawStraightLine(painter, firstP, secondP)
            return
        
        previousP = None
        nextP = None
        if sectionIndex == 0:
            lastDirection = self.sourceDirection()
        else:
            previousP = self.mapFromParent(self._route[sectionIndex -1])
            lastDirection = self.getPointToPointDirection(previousP, firstP)
        if sectionIndex > len(self._route) -3:
            nextDirection = self.targetDirection()
        else:
            nextP = self.mapFromParent(self._route[sectionIndex +2])
            nextDirection = self.getPointToPointDirection(secondP, nextP)
        
        firstCorner = self.getCornerType(lastDirection, direction)
        secondCorner = self.getCornerType(direction, nextDirection)
        
        minDist = self.CONNECTION_THICKNESS * self.zoomFactor() * 4
        maxRadius = None
        if previousP:
            xDist = abs(firstP.x() - previousP.x())
            yDist = abs(firstP.y() - previousP.y())
            if xDist > 0 and xDist < minDist:
                maxRadius = 0.5 * xDist
            elif yDist > 0 and yDist < minDist:
                maxRadius = 0.5 * yDist
                
        xDist = abs(firstP.x() - secondP.x())
        yDist = abs(firstP.y() - secondP.y())
        if xDist > 0 and xDist < minDist:
            maxRadius = 0.5 * xDist
        elif yDist > 0 and yDist < minDist:
            maxRadius = 0.5 * yDist
        #if maxRadius:
        self.drawCorner(painter, firstP, firstCorner, maxRadius)
        
#        print "_____________________ darawSection _______________________"
#        print "firstP", firstP
#        print "secondP", secondP
#        print "lastDirection", self.connectionDirectionString(lastDirection)
#        print "  firstCorner", self.cornerTypeString(firstCorner)
#        print "direction", self.connectionDirectionString(direction)
#        print "  secondCorner", self.cornerTypeString(secondCorner)
#        print "nextDirection", self.connectionDirectionString(nextDirection)
#        print "\n\n"
        
        thickness = self.CONNECTION_THICKNESS * self.zoomFactor()
        halfthick = thickness / 2
        cornerRoundness = halfthick ** 0.5
        cornerOffset = halfthick * cornerRoundness * (4 * self.zoomFactor()**2)
        innerCorner = halfthick * (cornerRoundness + 1)
        outerCorner = halfthick * (cornerRoundness - 1)
        
        rect = self.getRectBetweenTwoPoints(firstP, secondP, firstCorner, secondCorner)
            # Paint witch color gradient (PyQt4)
        if direction == self.ConnectionDirection.LEFT:     # horizontal, negative
            brush = QLinearGradient(rect.x(), rect.y(), rect.x(), rect.y() + halfthick)
        elif direction == self.ConnectionDirection.RIGHT:  # horizontal, positive
            brush = QLinearGradient(rect.x(), rect.y(), rect.x(), rect.y() + halfthick)
        elif direction == self.ConnectionDirection.UP:     # vertical, negative
            brush = QLinearGradient(rect.x(), rect.y(), rect.x() + halfthick, rect.y())
        elif direction == self.ConnectionDirection.DOWN:   # vertical, positive
            brush = QLinearGradient(rect.x(), rect.y(), rect.x() + halfthick, rect.y())
        else:
            # Should already be drawn above --> direction == self.ConnectionDirection.UNDEFINED
            return
        
        if painter.redirected(painter.device()):
            # e.q. QPixmap.grabWidget()
            painter.setBrush(self.FILL_COLOR1)
        else:
            brush.setSpread(QLinearGradient.ReflectSpread)
            brush.setColorAt(0, self.FILL_COLOR1)
            brush.setColorAt(1, self.FILL_COLOR2)
            painter.setBrush(brush)
        
        painter.drawRect(rect)
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:89,代码来源:PortConnection.py


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