Re: How to change color of Gtk::RadioButton's label?



Hello Marco,

I failed to note that your test case where the window and the
checkbutton classes are not derived and a simple window is created, your
method seems to work fine.  More to my eternal chagrin, the set_markup
methodology also works fine.  However, when the checkbutton in question
defined as a pointer in a derived window class (in an existing project
of mine) it doesn't seem to accept the addition of an outside
Gtk::Label.  I am sure, at this point, that this is because I've done
something stupidly wrong in creating and adding that label.

Nevertheless, I am still baffled as to why I'm getting the strange assertion

(testbg:25764): Pango-CRITICAL **: pango_attr_list_change: assertion
`list != NULL' failed

when I tried to use the Pango::Layout as illustrated in my message
replying to Paul Davis.

Bob

P.S.  I did call the "show_all_children" method for the modified
checkbutton:  no joy.

Marco Scholten wrote:

> From: "Bob Caryl" <bob fis-cal com>
> To: "Marco Scholten" <mscholtn xs4all nl>
> Cc: <gtkmm-list gnome org>
> Sent: Tuesday, December 20, 2005 3:55 PM
> Subject: Re: How to change color of Gtk::RadioButton's label?
>
>
>> Hello Marco,
>>
>> If the Pango::Layout is not useable for a Gtk::Label, then why oh why
>> does Gtk::Label::get_layout exist?  If Pango cannot be used to display a
>> Gtk::Label's text, then why in the wide wide world is the method listed
>> in the Gtk::Label documentation with the comment:  "Get's the
>> Pango::Layout used to display the label."
>
>
> Doesn't it?
>
>> My research shows that Gtk::Button does not have this method
>> specifically, nor does it exist in its ancestry.  Incidentally,
>> Gtk::EventBox also lacks get_layout specifically or in its ancestry.
>>
>> So, it appears that I'm back to either obtaining a handle to the button
>> class's internal label widget, or creating and adding my own label to
>> the button (which inexplicably has not worked for me so far.)
>>
>> Marco, I greatly appreciate your efforts here, but I cannot help but
>> believe that this can be done somehow with Pango.
>>
>
> Sure it can, with pango markup like this:
>
> Gtk::CheckButton b;
> Gtk::Label* l=Gtk::manage(new Gtk::Label);
>
> l->set_text("<span background = \"blue\"> blue background </span>");
> l->set_use_markup(true);
> b.add(*l);
>
> But this will not work for since adding a label to a button will not
> work for you, what if you add a call to show_all_children() for the
> window?.
>
> -- 
> Marco
>



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