[GObject Introspection] Getting style colors using GTK and Python
- From: Krzysztof Klinikowski <kkszysiu gmail com>
- To: gtk-devel-list gnome org
- Subject: [GObject Introspection] Getting style colors using GTK and Python
- Date: Sun, 22 Aug 2010 06:07:52 +0200
Hello. I need to get colors from used GTK style. Later, using PyGTK I
do things like:
def get_theme_colors(w = gtk.Window()):
w.realize()
style = w.get_style()
output = {}
for i in ["base", "text", "fg", "bg"]:
c = getattr(style, i)[gtk.STATE_NORMAL]
output[i] = Color.from_gtk_color(c)
c = getattr(style, i)[gtk.STATE_SELECTED]
output["%s_selected" % i] = Color.from_gtk_color(c)
return output
Now im trying to do using PyGI:
def get_theme_colors(w = gtk.Window()):
w.realize()
style = w.get_style()
output = {}
for i in ["base", "text", "fg", "bg"]:
print style.bg
c = getattr(style, i)[gtk.StateType.NORMAL]
output[i] = Color.from_gtk_color(c).hex
c = getattr(style, i)[gtk.StateType.SELECTED]
output["%s_selected" % i] = Color.from_gtk_color(c).hex
return output
But something like style.bg always prits me:
Segmentation fault (core dumped)
Question is why? Should I do that in different way? I have no idea.
Could anyone help me?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]