Re: changing label in a gtk2 stock item

On Jan 26, 2008, at 10:39 AM, zentara wrote:

Someone asked this on perlmonks, and I thought it would be easy.....
but not. :-)

They want to change just the Label of a button from stock_id.

Would you mind linking to the original post for some context? I'd really like to know *why* you'd want to change the label of a stock item, since it's generally a bad thing to do. (E.g., you hose translations and other uses in code you didn't write, etc, etc.)

On the other hand, if all you mean is that you want to create a new stock item that differs from an existing one by only the label and id, then that's another thing.

Or, if you mean that you want to change the label on a button that has already been created from a stock id, that one's easy --- $button- >set_label ($new_string);. If you want to change the text but not the image, then you're back to the warnings above about translations, and the extra need to dig through the widget tree with crazy code like this...

        sub find_and_set_label_in {
                my ($widget, $text) = @_;
                print "@_\n";
                if ($widget->isa (Gtk2::Container::)) {
                        $widget->foreach (sub { find_and_set_label_in ($_[0], $text); });
                } elsif ($widget->isa (Gtk2::Label::)) {
                        $widget->set_text ($text);
        find_and_set_label_in ($button->child, "Something");

So, info needed.

The stereo, playing the Beastie Boys' "Rhymin' and Stealin'": "I'll steal your girlie like I stole your bike!"

Elysse:  "You mean, take off the chain and ride away?"

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