本文整理汇总了Python中PySide.QtGui.QColor.isValid方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.isValid方法的具体用法?Python QColor.isValid怎么用?Python QColor.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.isValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setBaseColor
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import isValid [as 别名]
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()
示例2: convert_to_color
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import isValid [as 别名]
def convert_to_color ( object, name, value ):
""" Converts a number into a QColor object.
"""
# Handle the case of a number of the form: 0xAARRGGBB, where the alpha AA
# value is inverted (i.e. 00 = opaque, FF = transparent):
if isinstance( value, IntTypes ):
return QColor( int( (value >> 16) & 0xFF ),
int( (value >> 8) & 0xFF ),
int( value & 0xFF ),
int( 255 - ((value >> 24) & 0xFF) ) )
# Try the toolkit agnostic format.
try:
tup = eval( value )
except:
tup = value
if isinstance( tup, tuple ):
if 3 <= len( tup ) <= 4:
try:
color = QColor( *tup )
except TypeError:
raise FacetError
else:
raise FacetError
else:
if isinstance( value, basestring ):
# Allow for spaces in the string value.
value = value.replace( ' ', '' )
# Let the standard ctors handle the value.
try:
color = QColor( value )
except TypeError:
raise FacetError
if not color.isValid():
raise FacetError
return color