[pygtk] Generating theme-compatible colors
laszlok2 at gmail.com
Fri Feb 20 03:18:35 WST 2009
If fact the tango colours are designed to (generally) work together.
Think of an icon which requires more than three colours, and needs to
work well with all light and dark themes.
As long as any widget that you draw with the colours follows the tango
specs such that they are light with a darker border around it to
provide contrast, using any of the colours under any situation should
work fine. So just grab them at random if you need more than three.
I like how you solved the text colour issue too.
2009/2/19 Samuel Abels <newsgroups at debain.org>:
> In case anybody has the same problem, I solved it by creating a static
> list of colors (taken from the Tango specs), and choosing the text color
> depending on the sum of the color values. The code is here:
> (look at the from_string function in that file)
> It still has the drawback that you can only get three related colors,
> but that's probably enough in most cases.
> On Tue, 2009-02-17 at 01:12 +0100, Samuel Abels wrote:
>> 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?
>> pygtk mailing list pygtk at daa.com.au
>> Read the PyGTK FAQ: http://faq.pygtk.org/
> pygtk mailing list pygtk at daa.com.au
> Read the PyGTK FAQ: http://faq.pygtk.org/
More information about the pygtk