[Fwd: Re: Gtk2::MenuItem get_label?]



Back to some Gtk2-Perl hacking after a longer break ...
There is still one problem, where I didn't get an answer yet, see below. I'd really appreciate a way to get to all the labels. Thanks.

Martin

-------- Original Message --------
Subject: Re: Gtk2::MenuItem get_label?
Date: Tue, 22 Feb 2005 21:48:49 +0100
From: Martin Junius <mj+gnome ml m-j-s net>
To: Grant McLean <grant mclean net nz>
CC: gtk-perl mailing list <gtk-perl-list gnome org>
References: <421A5399 2050804 ml m-j-s net> <1109025257 20164 10 camel localhost>

Grant McLean wrote:

The Gtk2::MenuItem is derived from the Gtk::Bin class, so you can
use the ->child method to get the label object out.  Then you can use
the ->get_label method to get the text of the label.

  my $text = $menu_item->child->get_label;

Well, doesn't really work for me:

my $menu = $glade->get_widget($name1)->get_menu;
my @items = $menu->get_children;
for my $item (@items) {
    print "item=", $item, "\n";
    print "  child=", ($item->child ? $item->child : "undef"), "\n";
    print "  label=", ($item->child ? $item->child->get_label :
"undef"), "\n";
}

Output ($name1 is a Glade-2 generated option menu with 2 items "None"
and "Fade":

1. "None" selected

item=Gtk2::MenuItem=HASH(0x8d68df4)
  child=undef
  label=undef
item=Gtk2::MenuItem=HASH(0x8d690f4)
  child=Gtk2::AccelLabel=HASH(0x8d82e10)
  label=Fade

2. "Fade" selected

item=Gtk2::MenuItem=HASH(0x8d68e18)
  child=Gtk2::AccelLabel=HASH(0x8758d4c)
  label=None
item=Gtk2::MenuItem=HASH(0x8d69118)
  child=undef
  label=undef

So it seems I can only retrieve the label from menu items which are
*not* currently selected? Strange.

Martin
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list




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