[pygtk] [GTK3] get background color

2013-01-29 Thread Yann Leboulanger

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   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] [GTK3] get background color

2013-01-29 Thread Niklas Koep
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 aste...@lagaule.org

 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   pygtk@daa.com.au
 http://www.daa.com.au/mailman/**listinfo/pygtkhttp://www.daa.com.au/mailman/listinfo/pygtk
 Read the PyGTK FAQ: http://faq.pygtk.org/

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Re: [pygtk] [GTK3] get background color

2013-01-29 Thread Yann Leboulanger

On 01/29/2013 02:35 PM, Niklas Koep wrote:

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


No, this is done AFTER the widget is realized. It's done in a textbiffer 
'changed' callback, a long time (several seconds) after widget is shown.


Your code is what I used in pygtk, but I'm not able to find a working 
equivalent in pygobject.


--
Yann
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/