Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_color_click(self, widget):
self.done_lbl.set_text("")
gcolor = Gdk.RGBA()
gcolor.parse(widget.get_label())
dialog = ColorDialog(self.parent, self.selected_file, gcolor)
response = dialog.run()
if response == Gtk.ResponseType.OK:
r, g, b, _ = dialog.colorchooser.get_rgba()
rgb = list(map(lambda x: round(x*100*2.55), [r, g, b]))
hex_color = pywal.util.rgb_to_hex(rgb)
widget.set_label(hex_color)
gcolor = Gdk.color_parse(hex_color)
if util.get_hls_val(hex_color, 'light') < 100:
fgcolor = Gdk.color_parse('#FFFFFF')
else:
fgcolor = Gdk.color_parse('#000000')
widget.set_sensitive(True)
widget.modify_bg(Gtk.StateType.NORMAL, gcolor)
widget.modify_fg(Gtk.StateType.NORMAL, fgcolor)
for i, c in enumerate(self.button_list):
if c.get_label() != self.color_list[i]:
self.color_list[i] = c.get_label()
self.render_sample()
dialog.destroy()
def keyword_colors(hexc, is_dark_theme=True):
"""extract active and inactive colors from a given
hex color value"""
brightness = util.get_hls_val(hexc, "light")
active = util.alter_brightness(hexc, brightness * -0.20) \
if is_dark_theme else util.alter_brightness(hexc, brightness * 0.30)
inactive = util.alter_brightness(hexc, brightness * -0.45) \
if is_dark_theme else hexc
return {
"active": active,
"inactive": inactive,
"newfront": active,
"newback": inactive,
"newglyph": util.alter_brightness(inactive, -15)
}
def auto_adjust(colors):
"""create a clear foreground and background set of colors"""
light = settings.getboolean("light_theme", False)
if settings.getboolean("smart_sort", True):
colors = smart_sort(colors)
alter_brightness = util.alter_brightness
get_hls_val = util.get_hls_val
added_sat = 0.25 if light else 0.1
sign = -1 if light else 1
if light == is_dark_theme(colors):
colors[7], colors[0] = colors[0], colors[7]
comment = [alter_brightness(colors[0], sign * 25)]
fg = [alter_brightness(colors[7], sign * 60)]
colors = colors[:8] + comment \
+ [alter_brightness(x, sign * get_hls_val(x, "light") * 0.3, added_sat)
for x in colors[1:7]] + fg
return colors