Re: How to set background color of a Gtk::Label
- From: Guillaume Brocker <guillaume brocker digital-trainers com>
- To: gtkmm-list gnome org
- Subject: Re: How to set background color of a Gtk::Label
- Date: Tue, 01 Feb 2011 16:54:22 +0100
Le 01/02/2011 16:31, BALLABIO GERARDO a écrit :
Hi all, I've been trying to change the background color of a
Gtk::Label widget. After several unsuccessful attempts, yesterday I
was about to post asking for help, then I eventually found a
solution, but having seen that this question had been already asked
recently, I thought it'd be useful to let you know.
The solution I found is to wrap a Gtk::EventBox around the
Gtk::Label, and change the background of the former (using the
modify_bg method). Attached is a minimal example.
I think that is a good solution.
If I understand correctly what's going on, the Gtk::Label widget
actually doesn't draw its own background, but just draws the label
over whatever is there, which normally is the default background
color. Thus, changing the background color of the Gtk::Label doesn't
work because you're changing the color of something that's *never*
going to be drawn. The solution is to lay the Gtk::Label over another
widget that *does* draw its background, and change that.
Gtk::EventBox does the job -- if you think another widget is better
suited, please let me know.
You are right !
] [Thread Prev