Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setColor(self, color, selectedColor=None):
"""
Set the widget color.
"""
if selectedColor is None:
selectedColor = saturated(color, 150)
palette = create_palette(color, selectedColor)
self.shapeItem.setPalette(palette)
def create_palette(light_color, color):
"""
Return a new :class:`QPalette` from for the :class:`NodeBodyItem`.
"""
palette = QPalette()
palette.setColor(QPalette.Inactive, QPalette.Light, saturated(light_color, 50))
palette.setColor(QPalette.Inactive, QPalette.Midlight, saturated(light_color, 90))
palette.setColor(QPalette.Inactive, QPalette.Button, light_color)
palette.setColor(QPalette.Active, QPalette.Light, saturated(color, 50))
palette.setColor(QPalette.Active, QPalette.Midlight, saturated(color, 90))
palette.setColor(QPalette.Active, QPalette.Button, color)
palette.setColor(QPalette.ButtonText, QColor("#515151"))
return palette
def create_palette(light_color, color):
"""
Return a new :class:`QPalette` from for the :class:`NodeBodyItem`.
"""
palette = QPalette()
palette.setColor(QPalette.Inactive, QPalette.Light, saturated(light_color, 50))
palette.setColor(QPalette.Inactive, QPalette.Midlight, saturated(light_color, 90))
palette.setColor(QPalette.Inactive, QPalette.Button, light_color)
palette.setColor(QPalette.Active, QPalette.Light, saturated(color, 50))
palette.setColor(QPalette.Active, QPalette.Midlight, saturated(color, 90))
palette.setColor(QPalette.Active, QPalette.Button, color)
palette.setColor(QPalette.ButtonText, QColor("#515151"))
return palette
def create_palette(light_color, color):
"""
Return a new :class:`QPalette` from for the :class:`NodeBodyItem`.
"""
palette = QPalette()
palette.setColor(QPalette.Inactive, QPalette.Light, saturated(light_color, 50))
palette.setColor(QPalette.Inactive, QPalette.Midlight, saturated(light_color, 90))
palette.setColor(QPalette.Inactive, QPalette.Button, light_color)
palette.setColor(QPalette.Active, QPalette.Light, saturated(color, 50))
palette.setColor(QPalette.Active, QPalette.Midlight, saturated(color, 90))
palette.setColor(QPalette.Active, QPalette.Button, color)
palette.setColor(QPalette.ButtonText, QColor("#515151"))
return palette
def create_palette(light_color, color):
"""
Return a new :class:`QPalette` from for the :class:`NodeBodyItem`.
"""
palette = QPalette()
palette.setColor(QPalette.Inactive, QPalette.Light, saturated(light_color, 50))
palette.setColor(QPalette.Inactive, QPalette.Midlight, saturated(light_color, 90))
palette.setColor(QPalette.Inactive, QPalette.Button, light_color)
palette.setColor(QPalette.Active, QPalette.Light, saturated(color, 50))
palette.setColor(QPalette.Active, QPalette.Midlight, saturated(color, 90))
palette.setColor(QPalette.Active, QPalette.Button, color)
palette.setColor(QPalette.ButtonText, QColor("#515151"))
return palette