[jokosher-devel] Fwd: [pygtk] Generating theme-compatible colors



This is regarding a previous discussion on IRC about how we can make
the waveform colours match the current theme better. I remember we
pretty much concluded it was impossible to do and still look nice
unless we figure out some magical property in the colour values for
the tango palette. ie. All colours happen to be multiples of each
other or something.

However this guy on the pygtk seems a little more ambitious than us.


---------- Forwarded message ----------
From: Samuel Abels <newsgroups debain org>
Date: 2009/2/16
Subject: [pygtk] Generating theme-compatible colors
To: pyGTK Mailinglist <pygtk daa com au>


Hi,

I am looking for a way to automatically get a set of related colors that
go well with the current theme. Because multiple sets of colors are
needed, I can't simply use the theme color.

(Explanation: I am writing an application in which colored boxes are
added into a text field, and the colors of each box are picked
automatically depending on the user who added them.)

Has anyone done this before me? My current (braindead) approach looks
like this:

palette = [(0.12, 0.29, 0.49),
          ...
          (1.0,  0.90, 0.34)]
def from_string(string, n_colors = 3):
   first = string.__hash__() % (len(palette) - n_colors)
   if n_colors == 1:
       return palette[first]
   return [palette[i] for i in range(first, first + n_colors)]

This somewhat works, but the colors often don't go well with each other,
and a white box may be invisible on a theme in which textview widgets
have a white background.

Any idea how to do this properly?

-Samuel

_______________________________________________
pygtk mailing list   pygtk daa com au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]