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


Python QtGui.QColor类代码示例

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


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

示例1: _create_metallic_roughness_map

    def _create_metallic_roughness_map(self, metal_map, rough_map):

        metal = QImage(metal_map)
        rough = QImage(rough_map)
        metal_pixel = QColor()

        metal = metal.convertToFormat(QImage.Format_RGB32);
        rough = rough.convertToFormat(QImage.Format_RGB32);
        metal_uchar_ptr = metal.bits()
        rough_uchar_ptr = rough.bits()
        if (not metal.width() == rough.width()
                or not metal.height() == rough.height()):
            raise RuntimeError("Error processing material: {}. Metallic map and roughness map must have same dimensions.".format(self.maya_node))
        width = metal.width();
        height = metal.height();

        i = 0
        for y in range(height):
            for x in range(width):
                metal_color = struct.unpack('I', metal_uchar_ptr[i:i+4])[0]
                rough_color = struct.unpack('I', rough_uchar_ptr[i:i+4])[0]
                metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color))
                metal_uchar_ptr[i:i+4] = struct.pack('I', metal_pixel.rgb())
                i+=4
                
        output = ExportSettings.out_dir + "/"+self.name+"_metalRough.jpg"
        return output, metal
开发者ID:oxpi,项目名称:maya-glTF,代码行数:27,代码来源:glTFExport.py

示例2: loadContour

 def loadContour(self, contourData):
     logging.debug("In CPRAction::loadContour()")
     scenes = self._ilsa.scenes()
     contour = CPRContour(scenes, self._ilsa, self.cprClosed)
     for scene in scenes:
         if contourData["sceneId"] == scene.id:
             contour.scene = scene
         elif contourData["panoramicSceneId"] == scene.id:
             contour.setPanoramicPlane(scene.parent)
         elif contourData["transversalSceneId"] == scene.id:
             contour.setTransversalPlane(scene.parent)
     self.propertiesAction.addContour(contour)
     
     contour.loadPoints(contourData["points"])
         
     lc = contourData["lineColor"]
     alc = contourData["actualLineColor"]
     ts = contourData["transversalSize"]
     lineColor = QColor.fromRgbF(lc[0], lc[1], lc[2])
     actualLineColor = QColor.fromRgbF(alc[0], alc[1], alc[2])
     self.propertiesAction.changeLineColor(lineColor)
     self.propertiesAction.changeActualLineColor(actualLineColor)
     contour.setTransversalSize(ts)
     self.propertiesAction.slotActionVisible(contourData["visible"])
     self.propertiesAction.slotActionLock(contourData["locked"])
     self.propertiesAction.lock.setChecked(contourData["locked"])
开发者ID:aevum,项目名称:moonstone,代码行数:26,代码来源:cpraction.py

示例3: paintEvent

	def paintEvent(self, ev):
		if self.isEnabled():
			color = self.color
			colorBorder = [0.4, 0.4, 0.4]
		else:
			color = [0.8, 0.8, 0.8]
			colorBorder = [0.7, 0.7, 0.7]

		painter = QPainter(self)
		painter.setRenderHint(QPainter.Antialiasing)
		painter.setRenderHint(QPainter.HighQualityAntialiasing)

		if self.isChecked():
			pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
			pen.setWidth(2.0)
		else:
			pen = QPen(QColor.fromRgbF(colorBorder[0], colorBorder[1], colorBorder[2]))
			pen.setWidth(1.0)

		size = self.size()
		sizeCircle = 12.0
		x = size.width() / 2.0 - (sizeCircle / 2.0)
		y = size.height() / 2.0 - (sizeCircle / 2.0)
		rect = QRectF(x, y, sizeCircle, sizeCircle)
		painter.setPen(pen)
		painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
		painter.drawEllipse(rect)
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:27,代码来源:ColorWidget.py

示例4: fromStr

 def fromStr(name, a=255):
     if name in _Colorizer.__colorTable:
         c = QColor(_Colorizer.__colorTable[name])
     else:
         c = QColor(Qt.transparent)
     c.setAlpha(a)
     return c
开发者ID:RayRiver,项目名称:behavior-studio,代码行数:7,代码来源:alphabet.py

示例5: __init__

 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,代码行数:25,代码来源:scatterplotWidget.py

示例6: _set_pixmap_from_roi

 def _set_pixmap_from_roi(self, roi):
     if roi.visible:
         color = _display_color(roi.color, self.selected)
     else:
         color = QColor(Qt.transparent)
     self.pixmap = _ndarray_to_arraypixmap(roi.mask[self.slicer.slc.view_slice], color.toTuple())
     self.pixmapitem.setPixmap(self.pixmap)
     self.pixmapitem.setZValue(_foreground_roi_z if self.selected else _background_roi_z)
开发者ID:jthacker,项目名称:arrview,代码行数:8,代码来源:roi.py

示例7: setBaseColor

    def setBaseColor(newcolor):
        StyleHelper.requestedBaseColor = newcolor
        color = QColor()
        color.setHsv(newcolor.hue(), newcolor.saturation() * 0.7, 64 + newcolor.value() / 3)

        if color.isValid() and color != StyleHelper.baseColor:
            StyleHelper.baseColor = color
            for w in QApplication.topLevelWidgets():
                w.update()
开发者ID:nichollyn,项目名称:libspark,代码行数:9,代码来源:stylehelper.py

示例8: _fade

    def _fade(self, lineno):
        cursor = self._get_line_cursor(lineno)

        fmt = cursor.charFormat()
        color=QColor('black')
        color.setAlphaF(0.5)
        fmt.setForeground(color)
        cursor.beginEditBlock()
        cursor.mergeCharFormat(fmt)
        cursor.endEditBlock()
开发者ID:UManPychron,项目名称:pychron,代码行数:10,代码来源:patch_editor.py

示例9: _init_ui

    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,代码行数:55,代码来源:notification_widget.py

示例10: routeFinished

    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,代码行数:14,代码来源:mapviewer.py

示例11: startNewLineCollection

 def startNewLineCollection(self):
     self.lineCollections.append(LineCollection())
     self.openCollectionIdx += 1
     newColor = QColor()
     # http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
     '''
     rand = random.random()
     rand += 0.618033988749895
     rand %= 1
     '''
     phi = 0.618033988749895
     hue = self.openCollectionIdx * phi - floor(self.openCollectionIdx * phi)
     newColor.setHsv(int(hue*256), 120 + int(random.random()*(240-120+1)), 242)
     self.colors.append(newColor)
开发者ID:lauramossity,项目名称:nonplanar-reflections,代码行数:14,代码来源:ReflectionAnalysis.py

示例12: 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

示例13: syntax_format

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,代码行数:14,代码来源:python_syntax_formatter.py

示例14: __init__

 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,代码行数:15,代码来源:parallelCoordinateWidget.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.QColor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。