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


Python QColor.setNamedColor方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setNamedColor [as 别名]
 def __init__(self, size, dynamic, controller):
     layer.__init__(self,size,dynamic)
     self.controller = controller
     self.ready = False
     
     dotColor = QColor()
     dotColor.setNamedColor(self.controller.svgLayer.svg.dotPrototype.getAttribute('fill'))
     dotColor.setAlphaF(float(self.controller.svgLayer.svg.dotPrototype.getAttribute('fill-opacity')))
     self.dotColors = []
     i = 0
     while i <= 1.0:
         self.dotColors.append(QColor.fromRgbF(dotColor.redF(),dotColor.greenF(),dotColor.blueF(),i))
         i += dotColor.alphaF()
     
     self.dotWidth = self.controller.svgLayer.svg.dotPrototype.width()
     self.dotHeight = self.controller.svgLayer.svg.dotPrototype.height()
     
     self.halfDotWidth = self.dotWidth/2
     self.halfDotHeight = self.dotHeight/2
     
     self.xoffset = self.controller.scatterBounds[0]-self.halfDotWidth
     self.yoffset = self.controller.scatterBounds[3]-self.halfDotHeight
     
     self.xNonNumeric = (self.controller.svgLayer.svg.xNonNumericIcon.left() + self.controller.svgLayer.svg.xNonNumericIcon.right())/2 - self.halfDotWidth
     self.yNonNumeric = (self.controller.svgLayer.svg.yNonNumericIcon.top() + self.controller.svgLayer.svg.yNonNumericIcon.bottom())/2 - self.halfDotHeight
开发者ID:alex-r-bigelow,项目名称:compreheNGSive,代码行数:27,代码来源:scatterplotWidget.py

示例2: _init_ui

# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setNamedColor [as 别名]
    def _init_ui(self, txt):
        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)

        pal = QPalette()
        color = QColor()
        color.setNamedColor(self._window_bgcolor)
        color.setAlpha(255 * self._opacity)
        pal.setColor(QPalette.Background, color)

        self.setAutoFillBackground(True)
        self.setPalette(pal)

        wm, hm = 5, 5
        spacing = 8
        layout = QVBoxLayout()
        layout.setSpacing(spacing)
        layout.setContentsMargins(wm, hm, wm, hm)

        nlines, ts = self._generate_text(txt)

        qlabel = QLabel('\n'.join(ts))

        ss = 'QLabel {{color: {}; font-family:{}, sans-serif; font-size: {}px}}'.format(self._color,
                                                                                        self._font,
                                                                                        self._fontsize)
        qlabel.setStyleSheet(ss)
        layout.addWidget(qlabel)

        hlabel = QLabel('double click to dismiss')
        hlabel.setStyleSheet('QLabel {font-size: 10px}')

        hlayout = QHBoxLayout()

        hlayout.addStretch()
        hlayout.addWidget(hlabel)
        hlayout.addStretch()

        layout.addLayout(hlayout)

        self.setLayout(layout)

        font = QFont(self._font, self._fontsize)
        fm = QFontMetrics(font)

        pw = max([fm.width(ti) for ti in ts])
        ph = (fm.height() + 2) * nlines

        w = pw + wm * 2
        h = ph + (hm + spacing + 1) * 2

        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setFixedWidth(w)
        self.setFixedHeight(h)

        self.setMask(mask(self.rect(), 10))
开发者ID:OSUPychron,项目名称:pychron,代码行数:57,代码来源:notification_widget.py

示例3: paintEvent

# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setNamedColor [as 别名]
    def paintEvent(self, event):
        qp = QPainter()
        qp.begin(self)
        c = QColor()
        c.setNamedColor(self._window_bgcolor)

        h, s, l, a = c.getHsl()
        c.setHsl(h, s, 100, a)

        pen = QPen(c, 8, QtCore.Qt.SolidLine)
        qp.setPen(pen)

        qp.drawRoundedRect(event.rect(), 12, 12)
        qp.end()
开发者ID:OSUPychron,项目名称:pychron,代码行数:16,代码来源:notification_widget.py

示例4: syntax_format

# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setNamedColor [as 别名]
def syntax_format(color, style=''):
    """Return a QTextCharFormat with the given attributes.
    """
    _color = QColor()
    _color.setNamedColor(color)

    _format = QTextCharFormat()
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
开发者ID:jackcarter125,项目名称:popupcad,代码行数:16,代码来源:python_syntax_formatter.py

示例5: __init__

# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setNamedColor [as 别名]
 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'))
开发者ID:alex-r-bigelow,项目名称:compreheNGSive,代码行数:17,代码来源:parallelCoordinateWidget.py

示例6: selectionLayer

# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setNamedColor [as 别名]
class selectionLayer(layer):
    def __init__(self, size, dynamic, controller, prototypeDot):
        layer.__init__(self,size,dynamic)
        self.controller = controller
        self.points = set()
        
        self.dotColor = QColor()
        self.dotColor.setNamedColor(prototypeDot.getAttribute('fill'))
        self.dotColor.setAlphaF(float(prototypeDot.getAttribute('fill-opacity')))
        self.dotWidth = prototypeDot.width()
        self.xoffset = self.controller.svgLayer.svg.xZeroBar.left()-self.dotWidth/2+1
        #self.xoffset = self.controller.scatterBounds[0]-self.dotWidth/2+1
        self.dotHeight = prototypeDot.height()
        self.yoffset = self.controller.svgLayer.svg.yZeroBar.bottom()-self.dotWidth/2+1
        #self.yoffset = self.controller.scatterBounds[3]-self.dotHeight/2+1
        self.xNonNumeric = (self.controller.svgLayer.svg.xNonNumericIcon.left() + self.controller.svgLayer.svg.xNonNumericIcon.right())/2 - self.dotWidth/2
        self.yNonNumeric = (self.controller.svgLayer.svg.yNonNumericIcon.top() + self.controller.svgLayer.svg.yNonNumericIcon.bottom())/2 - self.dotHeight/2
    
    def handleFrame(self, event, signals):
        return signals
    
    def updateAxes(self):
        self.xoffset = self.controller.svgLayer.svg.xZeroBar.left()-self.dotWidth/2+1
        self.yoffset = self.controller.svgLayer.svg.yZeroBar.bottom()-self.dotWidth/2+1
    
    def update(self, points):
        self.points = points
    
    def draw(self,painter):
        self.reverseXratio = 1.0/self.controller.xAxisRatio
        self.reverseYratio = 1.0/self.controller.yAxisRatio
        
        self.image.fill(Qt.transparent)
        for x,y in self.controller.vData.get2dData(self.points,self.controller.app.currentXattribute,self.controller.app.currentYattribute):
            valuePairs = []
            if isinstance(x,list):
                if isinstance(y,list):
                    assert len(x) == len(y)
                    valuePairs = zip(x,y)
                else:
                    valuePairs = [(x0,y) for x0 in x]
            elif isinstance(y,list):
                valuePairs = [(x,y0) for y0 in y]
            else:
                valuePairs = [(x,y)]
            
            for x0,y0 in valuePairs:
                if x0 == None or (not isinstance(x0,int) and not isinstance(x0,float)) or math.isinf(x0) or math.isnan(x0):
                    x0 = self.xNonNumeric
                else:
                    x0 = self.xoffset + x0*self.reverseXratio
                
                if y0 == None or (not isinstance(y0,int) and not isinstance(y0,float)) or math.isinf(y0) or math.isnan(y0):
                    y0 = self.yNonNumeric
                else:
                    y0 = self.yoffset + y0*self.reverseYratio
                painter.fillRect(x0,y0,self.dotWidth,self.dotHeight,self.dotColor)
    
    def getPoints(self, x, y):
        lowX=self.controller.screenToDataSpace(x-self.controller.cursorXradius, self.controller.scatterBounds[0], self.controller.currentXaxis.minimum, self.controller.xAxisRatio)
        lowY=self.controller.screenToDataSpace(y+self.controller.cursorYradius, self.controller.scatterBounds[3], self.controller.currentYaxis.minimum, self.controller.yAxisRatio)
        highX=self.controller.screenToDataSpace(x+self.controller.cursorXradius, self.controller.scatterBounds[0], self.controller.currentXaxis.minimum, self.controller.xAxisRatio)
        highY=self.controller.screenToDataSpace(y-self.controller.cursorYradius, self.controller.scatterBounds[3], self.controller.currentYaxis.minimum, self.controller.yAxisRatio)
        
        if (x + self.controller.cursorXradius >= self.xNonNumeric) and (x - self.controller.cursorXradius <= self.xNonNumeric + self.dotWidth):
            xSet = self.controller.vData.axisLookups[self.controller.app.currentXattribute].categoricalKeys
        else:
            xSet = set()
        if (y + self.controller.cursorYradius >= self.yNonNumeric) and (y - self.controller.cursorYradius <= self.yNonNumeric + self.dotHeight):
            ySet = self.controller.vData.axisLookups[self.controller.app.currentXattribute].categoricalKeys
        else:
            ySet = set()
        
        return self.controller.vData.query2D(self.controller.app.currentXattribute,[(lowX,highX)],xSet,
                                             self.controller.app.currentYattribute,[(lowY,highY)],ySet)
开发者ID:alex-r-bigelow,项目名称:compreheNGSive,代码行数:77,代码来源:scatterplotWidget.py


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