On 07/31/2013 02:23 PM, Yann Leboulanger wrote:
Hi, I'm trying to get the background color of a textview. I use python / pygobject, but I don't think it's related to the language. I tried doing that: context = textview.get_style_context() state = Gtk.StateFlags.NORMAL color = context.get_background_color(state) I tried all possible states, but none returns the correct background color (white in my case) I precise that textview is already realized, this code is done in a callback. Any idea how to get it? Thanks in advance,
Here is a very simple test script that shows the problem. For me it always prints:
<Gdk.Color(red=0.000000, green=0.000000, blue=0.000000, alpha=0.000000)> -- 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()
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list