how to set background color GtkBox in Gtk+3?

2019-07-23 08:19发布

问题:

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);

回答1:

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.