Re: [pygtk] [GTK3] get background color
On 08/01/2013 02:00 AM, Osmo Salomaa wrote: Here is a very simple scrpit that shows the problem. For me it prints: Gdk.Color(red=0.00, green=0.00, blue=0.00, alpha=0.00) 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 I am under XFCE / GTK2 theme, so there is no such file in my theme. My gtkrc file has a base[NORMAL] = #ff line, but I don't know how to get that with gtk3. It should be possible as it's correctly rendered. style.lookup_color(theme_base_color) returns a 0, 0, 0, 0 color here. -- 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
01.08.2013 10:09, Yann Leboulanger wrote: On 08/01/2013 02:00 AM, Osmo Salomaa wrote: style.lookup_color(theme_base_color) returns a 0, 0, 0, 0 color here. OK, so that's theme-specific. Some color names might be available regardless of theme, but I don't know which ones; for example Gtk.InfoBar documentation explicitly mentions {info,warning,question,other}_{bg,fg}_color. I get the same (0,0,0,0) from get_background_color with your test script. I've ran into this issue before and I have just used those Adwaita names and a not-well-thought-out fallback if the lookup fails. Curiously, if I swap the text view in your script for an entry, I get the actual background color (white). In any reasonable theme, these should probably both use the base color. -- Osmo Salomaa otsal...@iki.fi ___ 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
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/
[pygtk] [GTK3] get background color
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
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
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/