[pygtk] Scraping colors from the current theme

Jeremy S dumbmatter at gmail.com
Tue Aug 5 12:43:50 WST 2008


I don't know the answer to most of your questions because I don't know
much about GTK themes, but the desktop background color for Gnome is
stored in gconf.  You can get it like this:

import gconf

client = gconf.client_get_default()
client.add_dir('/desktop/gnome/background', gconf.CLIENT_PRELOAD_NONE)

print client.get_string('/desktop/gnome/background/primary_color')
print client.get_string('/desktop/gnome/background/secondary_color')

2008/8/5 Someone <3m0mdpc02 at sneakemail.com>:
> I wanted to try my hand at writing a script to read the color scheme from
> Gnome and write it to Wine, but I haven't been very successful, even with
> much of the work done for me.  (I am the beginnerest of Python beginners,
> and thought it would be as simple as reading the colors from one file and
> translating them into the format expected by the other file.  I guess not.)
>
> See http://ubuntuforums.org/showthread.php?p=5506889#post5506889 for the
> current script and more details.
>
> I based the script on someone else's, but while some of their color mappings
> work, others are not right.  With the Ubuntu Human theme, for instance,
> this:
>
> menu1 = gtk.Menu()
> menuitem1 = gtk.MenuItem()
> menu1.add(menuitem1)
> menustyle = menuitem1.style
> menuselection = menustyle.bg[gtk.STATE_SELECTED]
>
> gives me a blue color, when the selected menu background is actually
> yellow.  I also don't know how to read the tooltip color:
>
> tooltips1 = gtk.Tooltips()
> tooltipstyle = tooltips1.style
> <type 'exceptions.AttributeError'>: 'gtk.Tooltips' object has no attribute
> 'style'
>
> Other colors I don't even think are part of PyGTK, like the Gnome desktop
> color, and window manager colors like the title bar and borders.  Can you
> confirm this for me?
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
>


More information about the pygtk mailing list