本文整理汇总了Python中AnyQt.QtGui.QColor.isValid方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.isValid方法的具体用法?Python QColor.isValid怎么用?Python QColor.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.isValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setWidgetCategory
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import isValid [as 别名]
def setWidgetCategory(self, desc):
"""
Set the widget category.
"""
self.category_description = desc
if desc and desc.background:
background = NAMED_COLORS.get(desc.background, desc.background)
color = QColor(background)
if color.isValid():
self.setColor(color)
示例2: DropShadowFrame
# 需要导入模块: from AnyQt.QtGui import QColor [as 别名]
# 或者: from AnyQt.QtGui.QColor import isValid [as 别名]
class DropShadowFrame(QWidget):
"""
A widget drawing a drop shadow effect around the geometry of
another widget (works similar to :class:`QFocusFrame`).
Parameters
----------
parent : :class:`QObject`
Parent object.
color : :class:`QColor`
The color of the drop shadow.
radius : float
Shadow radius.
"""
def __init__(self, parent=None, color=QColor(), radius=5,
**kwargs):
QWidget.__init__(self, parent, **kwargs)
self.setAttribute(Qt.WA_TransparentForMouseEvents, True)
self.setAttribute(Qt.WA_NoChildEventsForParent, True)
self.setFocusPolicy(Qt.NoFocus)
self.__color = QColor(color)
self.__radius = radius
self.__widget = None
self.__widgetParent = None
self.__updatePixmap()
def setColor(self, color):
"""
Set the color of the shadow.
"""
if not isinstance(color, QColor):
color = QColor(color)
if self.__color != color:
self.__color = QColor(color)
self.__updatePixmap()
def color(self):
"""
Return the color of the drop shadow.
By default this is a color from the `palette` (for
`self.foregroundRole()`)
"""
if self.__color.isValid():
return QColor(self.__color)
else:
return self.palette().color(self.foregroundRole())
color_ = Property(QColor, fget=color, fset=setColor, designable=True,
doc="Drop shadow color")
def setRadius(self, radius):
"""
Set the drop shadow's blur radius.
"""
if self.__radius != radius:
self.__radius = radius
self.__updateGeometry()
self.__updatePixmap()
def radius(self):
"""
Return the shadow blur radius.
"""
return self.__radius
radius_ = Property(int, fget=radius, fset=setRadius, designable=True,
doc="Drop shadow blur radius.")
def setWidget(self, widget):
"""
Set the widget around which to show the shadow.
"""
if self.__widget:
self.__widget.removeEventFilter(self)
self.__widget = widget
if self.__widget:
self.__widget.installEventFilter(self)
# Find the parent for the frame
# This is the top level window a toolbar or a viewport
# of a scroll area
parent = widget.parentWidget()
while not (isinstance(parent, (QAbstractScrollArea, QToolBar)) or \
parent.isWindow()):
parent = parent.parentWidget()
if isinstance(parent, QAbstractScrollArea):
parent = parent.viewport()
self.__widgetParent = parent
self.setParent(parent)
self.stackUnder(widget)
self.__updateGeometry()
self.setVisible(widget.isVisible())
#.........这里部分代码省略.........