views:

626

answers:

2

According to http://www.pygtk.org/docs/pygtk/gtk-constants.html, there are five state types: STATE_NORMAL, STATE_INSENSITIVE, etc. I want to set the background color of a Table, HBox, VBox, whatever, and I've tried setting every possible color of every kind of state:

    style = self.get_style()
    for a in (style.base, style.fg, style.bg,
              style.light, style.dark, style.mid,
              style.text, style.base, style.text_aa):
        for st in (gtk.STATE_NORMAL, gtk.STATE_INSENSITIVE,
                   gtk.STATE_PRELIGHT, gtk.STATE_SELECTED,
                   gtk.STATE_ACTIVE):
            a[st] = gtk.gdk.Color(0, 34251, 0)

Nothing has any effect. The only one that has any effect is when I manually created EventBoxes and specifically used the existing gtk.STATE_NORMAL color to blend with other colors. All the ones created by gtk without my intervention were not affected, though.

What's the proper way to go about doing this? I wouldn't mind having to make a gtkrc file or whatever. Is this because hbox, vbox, etc., don't have a color, but are transparent? Who provides the general color of the application, then?

+1  A: 

Mostly google-fu (no windows here), posting as an "answer" mostly for a slightly better formatting. See if experimenting with the full-blown gtkrc like the one from here brings the fruits. The location, based on this and this appears to vary - so unless someone has the deterministic approach of finding it, filemon could be a sensible approach.

Being mostly a user for these kinds of apps, I would prefer the settings from my gtkrc over the hardcoded by what the programmer thought would be "the best", anytime.

Andrew Y
can you put your gtkrc in a pastebin or something so I can take a look at how to do colors w/ it?
Claudiu
Done - http://pastebin.ca/1520931
Andrew Y
+1  A: 

It's because VBox and Hbox don't have an associated Window. click here to see other widgets without windows. I would create event boxes and add the HBox or VBox inside the event box.

saleh
neither does a gtk.Button, but this trick worked for them. (or maybe it does?). in any case, wrapping everything in event boxes ends up with pretty ugly things. i really just want to control the theme of my application somehow
Claudiu