Re:
- From: John McDermott <jjm jkintl com>
- To: gtk-perl-list gnome org, Raul Dias <chaos swi com br>
- Subject: Re:
- Date: Tue, 30 Oct 2001 10:10:09 -0700
Maybe you could use a closure:
foreach (qw(opt1 opt2 opt3 opt4)) {
my $menu_item = new Gtk::MenuItem ( $_ );
$menu_item->signal_connect('activate', sub { print "I have a
child\n" if defined $menu_item->child});
$menu_item->show;
$menu->append( $menu_item );
}
--john
From: Raul Dias <chaos swi com br>
To: gtk-perl-list gnome org
Subject: Problems getting the child of a Gtk::OptionMenu
hi,
I am trying to get the label of a MenuItem in a Gtk::OptionMenu.
I know it would be easier to just add a hash key for the string in to widgets, but
I want to use Gtk to do it.
what I have:
my $optionmenu = new Gtk::OptionMenu;
my $menu = new Gtk::Menu;
$menu->show;
$optionmenu->set_menu($menu);
$optionmenu->show;
foreach (qw(opt1 opt2 opt3 opt4)) {
my $menu_item = new Gtk::MenuItem ( $_ );
$menu_item->signal_connect('activate', \&callback);
$menu_item->show;
$menu->append( $menu_item );
}
sub callback {
my ($widget) = @_;
print "undefined child!\n" unless defined $widget->child;
}
As a Gtk::MenuItem Inherits from Gtk::Bin it has the method child() .
However the callback above will result in a undefined child.
The same happens with $widget->children() .
Am I missing something?
shouldn't there be a Gtk::Label instead of undef?
Regards,
Raul Dias
--__--__--
--
John McDermott, Writer and Consultant
J-K International, Ltd.
V +1 505/377-6293 F +1 505/377-6313
jjm jkintl com
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]