本文整理匯總了Python中PySide2.QtGui.QColor方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QColor方法的具體用法?Python QtGui.QColor怎麽用?Python QtGui.QColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySide2.QtGui
的用法示例。
在下文中一共展示了QtGui.QColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load_icon
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def load_icon(fname_icon):
path_this_file = os.path.abspath(__file__)
path_this_dir = os.path.dirname(path_this_file)
path_icons = os.path.join(path_this_dir, '..', 'media', 'icons')
path_icon = os.path.join(path_icons, fname_icon)
pixmap = QtGui.QPixmap(path_icon)
#pixmap.fill(QtGui.QColor('red'))
#pixmap.setMask(pixmap.createMaskFromColor(QtGui.QColor('black'), QtGui.Qt.MaskOutColor))
icon = QtGui.QIcon()
icon.addPixmap(pixmap, QtGui.QIcon.Normal)
icon.addPixmap(pixmap, QtGui.QIcon.Disabled)
return icon
示例2: initUI
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def initUI(self):
self._conicalGradient = QtGui.QConicalGradient(
self.width() / 2, self.height() / 2, 180)
for pos, (r, g, b) in CONICAL_GRADIENT:
self._conicalGradient.setColorAt(pos, QtGui.QColor(r, g, b))
top = self._rect.top()
bottom = self._rect.top() + self._rect.height()
self._vertical_gradient = QtGui.QLinearGradient(0, top, 0, bottom)
self._vertical_gradient.setColorAt(0.0, QtGui.QColor(*TRANSPARENT))
self._vertical_gradient.setColorAt(1.0, QtGui.QColor(BLACK))
left = self._rect.left()
right = self._rect.left() + self._rect.width()
self._horizontal_gradient = QtGui.QLinearGradient(left, 0, right, 0)
self._horizontal_gradient.setColorAt(0.0, QtGui.QColor(WHITE))
示例3: set_current_color
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def set_current_color(self, color):
[r, g, b] = color.getRgb()[:3]
self._angle = 360.0 - (QtGui.QColor(r, g, b).getHslF()[0] * 360.0)
self._angle = self._angle if self._angle != 720.0 else 0
x = ((((
sorted([r, g, b], reverse=True)[0] -
sorted([r, g, b])[0]) / 255.0) * self._rect.width()) +
self._rect.left())
y = ((((
255 - (sorted([r, g, b], reverse=True)[0])) / 255.0) *
self._rect.height()) + self._rect.top())
self._current_color = color
self._color_point = QtCore.QPoint(x, y)
self.repaint()
示例4: draw_editor
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def draw_editor(painter, rect, snap=None):
# draw border
pen = QtGui.QPen(QtGui.QColor('#333333'))
pen.setStyle(QtCore.Qt.DashDotLine)
pen.setWidth(3)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 25))
painter.setPen(pen)
painter.setBrush(brush)
painter.drawRect(rect)
if snap is None:
return
# draw snap grid
pen = QtGui.QPen(QtGui.QColor('red'))
painter.setPen(pen)
x = 0
y = 0
while y < rect.bottom():
painter.drawPoint(x, y)
x += snap[0]
if x > rect.right():
x = 0
y += snap[1]
示例5: __init__
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def __init__(self, name=None):
pen = QtGui.QPen(QtCore.Qt.SolidLine)
pen.setColor(QtGui.QColor(0, 0, 0, 255))
pen.setWidthF(0.2)
pen.setJoinStyle(QtCore.Qt.MiterJoin)
self.pen = pen
self.brush = QtGui.QBrush(QtGui.QColor(255, 255, 0, 255))
self.font = QtGui.QFont('Decorative', 12)
self.rect = QtCore.QRectF()
self.shape = QtGui.QPainterPath()
self.path = QtGui.QPainterPath()
self.scale = (1, 1)
self.tooltip = ''
self.method = ''
self.args = []
示例6: __init__
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.view = args[1]
# set pen and brush (filling)
self.pen = QtGui.QPen()
self.pen.setStyle(QtCore.Qt.DotLine)
self.pen.setColor(QtGui.QColor(80, 80, 100))
self.brush = QtGui.QBrush()
color = QtGui.QColor(20, 20, 80, 30)
self.brush.setColor(color)
# self.brush.setStyle(QtCore.Qt.NoBrush)
self.brush.setStyle(QtCore.Qt.SolidPattern)
# set style selectively for the rubberband like that
# see: http://stackoverflow.com/questions/25642618
# required as opacity might not work
# NOTE: opacity removed here
self.setStyle(QtWidgets.QStyleFactory.create('windowsvista'))
# set boolean for allowing zoom
self.allow_zoom = False
示例7: makeChord
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def makeChord(self):
line = gic.GraphicsCollection()
color = QtGui.QColor(70, 70, 70, 255)
line.pen.setColor(color)
line.pen.setWidthF(0.8)
# no pen thickness change when zoomed
line.pen.setCosmetic(True)
# setting CustomDashLine not needed as it will be set
# implicitely by Qt when CustomDashLine is applied
# put it just for completness
line.pen.setStyle(QtCore.Qt.CustomDashLine)
stroke = 10
dot = 2
space = 5
line.pen.setDashPattern([stroke, space, dot, space])
index_min = np.argmin(self.raw_coordinates[0])
index_max = np.argmax(self.raw_coordinates[0])
line.Line(self.raw_coordinates[0][index_min],
self.raw_coordinates[1][index_min],
self.raw_coordinates[0][index_max],
self.raw_coordinates[1][index_max])
self.chord = GraphicsItem.GraphicsItem(line)
self.chord.setAcceptHoverEvents(False)
示例8: makeSplineMarkers
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def makeSplineMarkers(self):
"""Create marker for polygon contour"""
self.splineMarkers = list()
for x, y in zip(*self.spline_data[0]):
# put airfoil contour points as graphicsitem
splinemarker = gic.GraphicsCollection()
splinemarker.pen.setColor(QtGui.QColor(60, 60, 80, 255))
splinemarker.brush.setColor(QtGui.QColor(180, 180, 50, 230))
splinemarker.pen.setWidthF(1.6)
# no pen thickness change when zoomed
splinemarker.pen.setCosmetic(True)
splinemarker.Circle(x, y, 0.004)
splineMarkerItem = GraphicsItem.GraphicsItem(splinemarker)
self.splineMarkers.append(splineMarkerItem)
示例9: test_takes_with_representations_shows_in_blue
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def test_takes_with_representations_shows_in_blue(self):
"""testing if takes with representations will be displayed in blue
"""
# select project 1 -> task1
item_model = self.dialog.tasks_treeView.model()
selection_model = self.dialog.tasks_treeView.selectionModel()
index = item_model.index(0, 0)
project1_item = item_model.itemFromIndex(index)
self.dialog.tasks_treeView.expand(index)
task1_item = project1_item.child(0, 0)
selection_model.select(
task1_item.index(),
QtGui.QItemSelectionModel.Select
)
# expect only one "Main" take listed in take_listWidget
main_item = self.dialog.takes_listWidget.item(0)
item_foreground = main_item.foreground()
color = item_foreground.color()
self.assertEqual(
color,
QtGui.QColor(0, 0, 255)
)
示例10: __init__
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def __init__(self):
super(_QDarkPalette, self).__init__()
self._color_white = QColor(255, 255, 255)
self._color_black = QColor(0, 0, 0)
self._color_red = QColor(255, 0, 0)
self._color_primary = QColor(53, 53, 53)
self._color_secondary = QColor(35, 35, 35)
self._color_tertiary = QColor(42, 130, 218)
self.setColor(QPalette.Window, self._color_primary)
self.setColor(QPalette.WindowText, self._color_white)
self.setColor(QPalette.Base, self._color_secondary)
self.setColor(QPalette.AlternateBase, self._color_primary)
self.setColor(QPalette.ToolTipBase, self._color_white)
self.setColor(QPalette.ToolTipText, self._color_white)
self.setColor(QPalette.Text, self._color_white)
self.setColor(QPalette.Button, self._color_primary)
self.setColor(QPalette.ButtonText, self._color_white)
self.setColor(QPalette.BrightText, self._color_red)
self.setColor(QPalette.Link, self._color_tertiary)
self.setColor(QPalette.Highlight, self._color_tertiary)
self.setColor(QPalette.HighlightedText, self._color_black)
示例11: paint
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def paint(self, painter, option, widget):
lod = option.levelOfDetailFromTransform(painter.worldTransform())
should_highlight = self._should_highlight()
if should_highlight:
pen = QPen(QColor(0, 0xfe, 0xfe), 2, self.style)
else:
pen = QPen(self.color, 2, self.style)
painter.setPen(pen)
painter.drawPath(self.path)
# arrow
if lod < 0.3:
return
# arrow
if should_highlight:
brush = QBrush(QColor(0, 0xfe, 0xfe))
else:
brush = QBrush(self.color)
painter.setBrush(brush)
painter.drawPolygon(self.arrow)
示例12: getColor
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def getColor(color):
if isinstance(color, QtGui.QColor) or isinstance(color, QtGui.QGradient):
return color
elif hasattr(color, "addColorStop"):
return color.value
elif not color:
return QtCore.Qt.transparent
else:
if isinstance(color, int):
color = hex(color)
if color[0 : 2].lower() == "0x":
color = "#" + color[2 ::]
colorObj = QtGui.QColor()
colorObj.setNamedColor(color)
return colorObj
示例13: main
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def main():
app = QApplication(sys.argv)
viewer = quarter.QuarterWidget()
root = coin.SoSeparator()
root += coin.SoCone()
root += test()
viewer.setSceneGraph(root)
viewer.setBackgroundColor(QColor(255, 255, 255))
viewer.setWindowTitle("minimal")
viewer.show()
sys.exit(app.exec_())
示例14: setBackgroundColor
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def setBackgroundColor(self, color):
"""Set backgroundcolor to a given QColor
Remember that QColors are given in integers between 0 and 255, as
opposed to SbColor4f which is in [0 ,1]. The default alpha value for
a QColor is 255, but you'll probably want to set it to zero before
using it as an OpenGL clear color."""
if isinstance(color, QtGui.QColor):
bgcolor = coin.SbColor4f(max(0, min(1, color.red() / 255.0)),
max(0, min(1, color.green() / 255.0)),
max(0, min(1, color.blue() / 255.0)),
max(0, min(1, color.alpha() / 255.0)))
self.sorendermanager.setBackgroundColor(bgcolor)
else:
self.sorendermanager.setBackgroundColor(coin.SbColor4f(color))
示例15: getBackgroundColor
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QColor [as 別名]
def getBackgroundColor(self):
""" Returns color used for clearing the rendering area before
rendering the scene."""
bg = self.sorendermanager.getBackgroundColor()
return QtGui.QColor(max(0, min(255, int(bg[0] * 255.0))),
max(0, min(255, int(bg[1] * 255.0))),
max(0, min(255, int(bg[2] * 255.0))),
max(0, min(255, int(bg[3] * 255.0))))