本文整理汇总了Python中Qt.QtGui.QColor方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QColor方法的具体用法?Python QtGui.QColor怎么用?Python QtGui.QColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Qt.QtGui
的用法示例。
在下文中一共展示了QtGui.QColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generateAlternateColorMultiplier
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def _generateAlternateColorMultiplier(color, av):
"""
Generate a multiplier based on the input color lighness to increase
the alternate value for dark color or reduce it for bright colors.
:param color: Input color.
:type color: QColor.
:param av: Alternate value.
:type av: Int.
"""
lightness = color.lightness()
mult = float(lightness)/255
return mult
示例2: paint
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def paint(self, painter, option, widget):
"""
Paint the Slot.
"""
painter.setBrush(self.brush)
painter.setPen(self.pen)
nodzInst = self.scene().views()[0]
config = nodzInst.config
if nodzInst.drawingConnection:
if self.parentItem() == nodzInst.currentHoveredNode:
painter.setBrush(utils._convertDataToColor(config['non_connectable_color']))
if (self.slotType == nodzInst.sourceSlot.slotType or (self.slotType != nodzInst.sourceSlot.slotType and self.dataType != nodzInst.sourceSlot.dataType)):
painter.setBrush(utils._convertDataToColor(config['non_connectable_color']))
else:
_penValid = QtGui.QPen()
_penValid.setStyle(QtCore.Qt.SolidLine)
_penValid.setWidth(2)
_penValid.setColor(QtGui.QColor(255, 255, 255, 255))
painter.setPen(_penValid)
painter.setBrush(self.brush)
painter.drawEllipse(self.boundingRect())
示例3: paint
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def paint(self, painter, option, widget=None):
"""Re-implement paint method
"""
# Define pen
palette = (self.scene().palette() if self.scene()
else option.palette)
pen = QtGui.QPen()
pen.setBrush(palette.highlight())
pen.setCosmetic(True)
pen.setWidth(self._outline)
pen.setStyle(QtCore.Qt.DashLine)
# Draw Shape
painter.setPen(pen)
# painter.drawPath(self._shape)
color = palette.highlight().color()
color.setAlphaF(0.2)
painter.setBrush(QtGui.QColor(color))
painter.drawRect(self.shape().controlPointRect())
return
示例4: __init__
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def __init__(self, raw_node):
super(UIStickyNote, self).__init__(raw_node)
self.color = QtGui.QColor(255, 255, 136)
self.color.setAlpha(255)
self.labelTextColor = QtGui.QColor(0, 0, 0, 255)
self.resizable = True
self.roundness = 1
self.textInput = InputTextField(
"Text Goes Here", self, singleLine=False)
self.textInput.setPos(QtCore.QPointF(
5, self.nodeNameWidget.boundingRect().height()))
self.textInput.document().contentsChanged.connect(self.updateSize)
self.textInput.editingFinished.connect(self.editingFinished)
self.textInput.startEditing.connect(self.startEditing)
self.textWidget = QGraphicsWidget()
self.textWidget.setGraphicsItem(self.textInput)
self.nodeLayout.addItem(self.textWidget)
self.NonFormatedText = self.textInput.toPlainText()
self.updateSize()
示例5: __init__
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def __init__(self, raw_tick, parent=None):
"""
:param raw_tick: Input Core Tick
:type raw_tick: :obj:`PyFlow.Core.structs.Tick`
:param parent: Parent QWidget
:type parent: QtWidgets.QWidget, optional
"""
super(uiTick, self).__init__(parent)
self.setAcceptHoverEvents(True)
self._width = 6
self._height = 6
self.hovered = False
self.setFlag(QtWidgets.QGraphicsWidget.ItemIsMovable)
self.setFlag(QtWidgets.QGraphicsWidget.ItemIsFocusable)
self.setFlag(QtWidgets.QGraphicsWidget.ItemIsSelectable, True)
self.setFlag(QtWidgets.QGraphicsWidget.ItemSendsGeometryChanges)
self._rawTick = raw_tick
self._color = QtGui.QColor(0)
示例6: addItem
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def addItem(self, u=0, v=[0, 0, 0], raw_item=None):
"""Adds a new Item to the ramp
:param u: X postion for the item, defaults to 0
:type u: float, optional
:param v: color value for the item, defaults to [0,0,0]
:type v: [float,float,float], optional
:param raw_item: Existing :obj:`PyFlow.Core.structs.Tick` to link with, if none, one new created , defaults to None
:type raw_item: :obj:`PyFlow.Core.structs.Tick`, optional
"""
if raw_item is None:
raw_item = self._rawRamp.addItem(u, v)
item = uiTick(raw_item)
item.setSelected(raw_item.isSelected())
item._width = 10
item._height = 17
r, g, b = v
item._color = QtGui.QColor.fromRgb(r, g, b)
self._scene.addItem(item)
self.updateItemPos(item)
示例7: drawBackground
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def drawBackground(self, painter, rect):
super(pyf_RampColor, self).drawBackground(painter, rect)
if len(self.items()):
b = QtGui.QLinearGradient(0, 0, rect.width(), 0)
if not self.bezier:
for item in self.items():
b.setColorAt(item.getU(), item.getColor())
else:
items = self.sortedItems()
numSteps = 50
for k in range(numSteps):
t = float(k) / (numSteps - 1)
color = []
for i in range(len(items[0].getV())):
color.append(self._rawRamp.interpolateBezier([p.getV()[i] for p in items], 0, len(items) - 1, t))
x = self._rawRamp.interpolateBezier([p.getU() for p in items], 0, len(items) - 1, t)
b.setColorAt(x, QtGui.QColor().fromRgb(color[0], color[1], color[2]))
else:
b = editableStyleSheet().InputFieldColor
painter.fillRect(rect, b)
示例8: __init__
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def __init__(self, dataType, parent=None):
super(_PinWidget, self).__init__(parent)
self.dataType = dataType
self.fakeOwningNode = _FakeNode()
self._rawPin = _FakePin()
self._pinColor = QtGui.QColor(*findPinClassByType(self.dataType).color())
self.labelColor = QtCore.Qt.white
self.hovered = False
self.pinSize = _PIN_SIZE
self._font = QtGui.QFont("Consolas")
self._font.setPointSize(14)
self.direction = PinDirection.Input
self.name = self.dataType
self.bLabelHidden = False
self.pinCircleDrawOffset = QtCore.QPointF()
self.setMouseTracking(True)
self.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
示例9: setColor
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def setColor(self, name, color, update=False):
value = color
if not isinstance(color, QtGui.QColor):
if isinstance(color, list) and len(color) >= 3:
a = 255
if len(color) == 4:
a = color[3]
color = QtGui.QColor(color[0], color[1], color[2], a)
for objname, obj in inspect.getmembers(self):
if objname == name:
if isinstance(obj, QtGui.QColor):
obj.setRgba(color.rgba())
elif isinstance(obj, list):
if isinstance(value, list):
value = value[0]
obj[0] = value
if update:
self.updateApp()
示例10: format
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def 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
# Syntax styles that can be shared by all languages
示例11: drawGroups
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def drawGroups(node, painter, option, widget):
inputsOffset = QtCore.QPointF(-2, 0)
outputsOffset = QtCore.QPointF(2, 0)
painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255, 200), 0.5))
for grp in node.groups["input"].values():
if grp.hovered and grp.expanded:
if grp.numPins() > 0:
grpPos = grp.geometry().bottomLeft()
lastPinPos = grp._pins[grp.numPins(
) - 1].geometry().bottomLeft()
painter.drawLine(grpPos, grpPos + inputsOffset)
painter.drawLine(grpPos + inputsOffset,
lastPinPos + inputsOffset)
painter.drawLine(lastPinPos + inputsOffset, lastPinPos)
for grp in node.groups["output"].values():
if grp.hovered and grp.expanded:
if grp.numPins() > 0:
grpPos = grp.geometry().bottomRight()
lastPinPos = grp._pins[grp.numPins(
) - 1].geometry().bottomRight()
painter.drawLine(grpPos, grpPos + outputsOffset)
painter.drawLine(grpPos + outputsOffset,
lastPinPos + outputsOffset)
painter.drawLine(lastPinPos + outputsOffset, lastPinPos)
示例12: format_
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def 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
# Syntax styles that can be shared by all languages
示例13: str_to_color
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def str_to_color(color_string):
"""Create QColor from comma sepparated RGBA string"""
return QtGui.QColor(*[int(c.strip()) for c in color_string.split(',')])
示例14: color_to_str
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def color_to_str(color):
"""Create comma separated RGBA string from QColor"""
return ", ".join([str(color.red()), str(color.green()), str(color.blue()), str(color.alpha())])
示例15: createRules
# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QColor [as 别名]
def createRules(self):
super(MasterUSDHighlighter, self).createRules()
# Support triple quote strings. Doesn't deal with escaped quotes.
self.multilineRules.append(createMultilineRule('"""', '"""', QtCore.Qt.darkGreen, QtGui.QColor(25, 255, 25)))