[GObject Introspection] Getting style colors using GTK and Python



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]