Claudiu
Claudiu

Reputation: 229561

In GTK on Windows, how do I change the background color of the whole app?

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?

Upvotes: 1

Views: 2377

Answers (3)

Steven T. Snyder
Steven T. Snyder

Reputation: 6177

You need to call self.set_style(style) after changing the style. I used your code as a template and adding that line makes the background of everything green.

Upvotes: 0

saleh
saleh

Reputation: 453

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.

Upvotes: 1

Andrew Y
Andrew Y

Reputation: 5117

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.

Upvotes: 2

Related Questions