Re: [pygtk] [GTK3] get background color

2013-07-31 Thread Osmo Salomaa
> Here is a very simple scrpit that shows the problem. For me it prints:
> 

For editable text fields, you're probably looking for the *base* color.

style.lookup_color("theme_base_color")

For Adwaita, you can find the available color names in gtk-main.css [1],
but I really don't know if they work across different themes.

[1]
https://git.gnome.org/browse/gnome-themes-standard/tree/themes/Adwaita/gtk-3.0/gtk-main.css

-- 
Osmo Salomaa 
___
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-07-31 Thread Yann Leboulanger

On 07/31/2013 09:03 PM, Yann Leboulanger wrote:

On 07/31/2013 07:33 PM, Timo wrote:

Op 31-07-13 13:48, Yann Leboulanger schreef:

On 01/29/2013 02:18 PM, Yann Leboulanger wrote:

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?



I still can't get it working with GTK-3.8.2 and python3-gi 3.8.3

Any idea?


Did you wait untill the treeview is realized?

treeview.connect('realize', get_bg_color)

def get_bg_color(widget):
 style = widget.get_style_context()
 bgcolor = style.get_background_color(Gtk.StateType.NORMAL)
 print(bgcolor)


Yes treeview is realized for sure, this code happens in a callback when
I press a key.



Here is a very simple scrpit that shows the problem. For me it prints:


--
Yann
from gi.repository import Gtk

def on_button_clicked(button, tv):
style = tv.get_style_context()
bgcolor = style.get_background_color(Gtk.StateType.NORMAL) 
print(bgcolor) 

win = Gtk.Window()
vb = Gtk.VBox()
tv = Gtk.TextView()
vb.add(tv)
button = Gtk.Button('get bg')
vb.add(button)
button.connect('clicked', on_button_clicked, tv)

win.add(vb)
win.show_all()

win.connect('delete-event', Gtk.main_quit)

Gtk.main()
___
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-07-31 Thread Yann Leboulanger

On 07/31/2013 07:33 PM, Timo wrote:

Op 31-07-13 13:48, Yann Leboulanger schreef:

On 01/29/2013 02:18 PM, Yann Leboulanger wrote:

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?



I still can't get it working with GTK-3.8.2 and python3-gi 3.8.3

Any idea?


Did you wait untill the treeview is realized?

treeview.connect('realize', get_bg_color)

def get_bg_color(widget):
 style = widget.get_style_context()
 bgcolor = style.get_background_color(Gtk.StateType.NORMAL)
 print(bgcolor)


Yes treeview is realized for sure, this code happens in a callback when 
I press a key.


--
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-07-31 Thread Timo

Op 31-07-13 13:48, Yann Leboulanger schreef:

On 01/29/2013 02:18 PM, Yann Leboulanger wrote:

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?



I still can't get it working with GTK-3.8.2 and python3-gi 3.8.3

Any idea?


Did you wait untill the treeview is realized?

treeview.connect('realize', get_bg_color)

def get_bg_color(widget):
style = widget.get_style_context()
bgcolor = style.get_background_color(Gtk.StateType.NORMAL)
print(bgcolor)


Cheers,
Timo
___
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-07-31 Thread Yann Leboulanger

On 01/29/2013 02:18 PM, Yann Leboulanger wrote:

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?



I still can't get it working with GTK-3.8.2 and python3-gi 3.8.3

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


[pygtk] [PyGObject] bindings

2013-07-31 Thread Yann Leboulanger

Hi,

I'm trying to port a pygtk code to gobject introspection, and I'm trying 
to find the equivalent of gtk.binding_entry_add_signal


it seems there is a Gtk.binding_entry_add_signall (2 l at the end ??), 
but it needs a Gtk.BindingSet as argument. and the gtk_binding_set_new 
doesn't seem to be available through PyGObject.


Am I wrong? Is there another way to create bindings?

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