how to set background color GtkBox in Gtk+3?
Asked Answered
F

1

1

I create application in GTK+3 and I Would like to change the background color for GtkBox but can not here this code:

box.modify_bg(Gtk.StateType.NORMAL, color);
Frascati answered 23/6, 2012 at 3:6 Comment(0)
D
8

In "Common Questions" of GTK+3 is the answer to your question.

In the basic form, you can use:

box.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(.5,.5,.5,.5))

In this case, the color will be a soft grey, half transparent. Probably, you want to paint it during the draw signal.

Diplomat answered 2/10, 2012 at 20:18 Comment(3)
I wish they did not deprecated the KISS interface.Alcyone
This answer is no longer valid: "gtk_widget_override_background_color has been deprecated since version 3.16 and should not be used in newly-written code."Oblique
@Oblique Indeed. Thanks for pointing out. With some time, we can update the answer to provide a more comprehensive example. If you need it in a rush, you may want to check mail.gnome.org/archives/gtk-app-devel-list/2016-August/… Also, you are very welcome to update the answer :-)Diplomat

© 2022 - 2024 — McMap. All rights reserved.