Claudiu
Claudiu

Reputation: 229401

in GTK, how do I get the original normal bg color of a widget?

I do this:

    self.origbg = self.style.bg[gtk.STATE_NORMAL]

and later in my eventboxes I change the bgcolor to it by doing:

    self.modify_bg(gtk.STATE_NORMAL, color)

However, the color actually changes! It's not the state_normal color that I get from looking at self.style.bg . On my Windows, it's a slightly lighter tint. How do I get the real background color?

Upvotes: 1

Views: 2222

Answers (3)

oxidworks
oxidworks

Reputation: 1642

I use this to get the default background color for an entry in GTK3

   context = entry.get_style_context()
   default_background = context.get_background_color(Gtk.StateType.NORMAL)

Upvotes: 0

MeanEYE
MeanEYE

Reputation: 967

If you want to avoid listening for map event you should call realize() and then get colors. I know this is an old issue but just wanted to contribute in case people run into it like I did. :)

Upvotes: 3

u0b34a0f6ae
u0b34a0f6ae

Reputation: 49813

Connect to the widget's "map-event" signal (which is sent when the widget is first shown in a window); this is the first time you can read the real theme colors.

Upvotes: 1

Related Questions