Re: How to change GTK+3 label color dynamically



Thanks! In some containers we can't change color of label? I have labels 
inside GtkLayout, and don't change color with Css but other labels out 
of this layout change.

Why don't works?

I do this dynamically but don't works too:

GtkCssProvider *css_provider = gtk_css_provider_new();
     gtk_css_provider_load_from_data (css_provider,
                                  "#label_Sensors {"
                                  "  color: red;"
                                  "}",
                                  -1,
                                  NULL);
     gtk_style_context_add_provider 
(gtk_widget_get_style_context(gtk_builder_get_object(builder,"Home_Sensors_Spare_window")),
                                 GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
     g_object_unref(css_provider);




On 16-03-2017 10:23, Stefan Salewski wrote:
On Thu, 2017-03-16 at 09:55 +0000, Rúben Rodrigues wrote:
Hi,

THanks. This is dynamically? I need in c language if possible :S

Thanks
Yes. The example

https://github.com/ngtk3/nim-gtk3/blob/master/test/colors.nim

is dynamically, I used it to generate some color schemes. Entered color
hex value in a text entry widget, and that color was applied.

As I said, it was working for 3.18. I think for 3.20 and above some CSS
names have changed, I had not the time to really investigate that.

I have no C code currently, I think my Nim code was inspired by Python
code, but I have no link to that python code currently. For C it is the
same pattern -- generate a CSS string and apply it.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]