Get Colors Of Current Gtk Style
I use PyGTK and I want to get colors of a widget (for example bg color), I run such a code: gdkColorToRgb = lambda gc: (gc.red//257, gc.green//257, gc.blue//257) widget = gtk.HBox(
Solution 1:
I just stumbled upon the same issue, saw your question and found a solution: You have to wait until the widget is realized, e.g. like this:
def print_style(widget):
style = widget.get_style()
for i in range(5):
print i, gdkColorToRgb(style.bg[i])
gdkColorToRgb = lambda gc: (gc.red//257, gc.green//257, gc.blue//257)
widget = gtk.HBox() ## for example
widget.connect('realize', print_style)
Post a Comment for "Get Colors Of Current Gtk Style"