Sounds like you're trying to retrieve the default colors before the widget
has been realized. Consider this (mind you this uses pygtk):

#!/usr/bin/env python

import gtk


def main():
    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.connect("delete-event", lambda *x: gtk.main_quit())

    tv = gtk.TreeView()
    tv.set_size_request(400, 250)

    def realize(tv): print tv.get_style().bg[gtk.STATE_ACTIVE]
    tv.connect("realize", realize)
    realize(tv)

    window.add(tv)
    window.show_all()

    gtk.main()

if __name__ == "__main__":
    main()


The output of this example on my machine is

#dcdad5
#f0f0f0

which just goes to show that the colors before and after realization
(might) differ.

Regards, Niklas



2013/1/29 Yann Leboulanger <[email protected]>

> Hi,
>
> I'm trying to get the default / current background color of a textview.
> The code I do it:
>
> context = tv.get_style_context()
> color = context.get_background_color(**Gtk.StateFlags.NORMAL)
>
> But that returns a fully transparent color (0,0,0,0)
>
> If I first set a custom color with tv.override_background_color()**, then
> get_background_color() correctly works and returns the color I set.
>
> So how can I get the current default color?
>
> Thanks in advanced
> --
> Yann
> ______________________________**_________________
> pygtk mailing list   [email protected]
> http://www.daa.com.au/mailman/**listinfo/pygtk<http://www.daa.com.au/mailman/listinfo/pygtk>
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to