On Aug 4, 2005, at 6:37 AM, Beast wrote:
muppet wrote:
my $self = $class->SUPER::new(...);
bless $self, $class;
Sorry, newbie question:
How do I set text $name from other subroutine?
----
new {
my $self = $class->SUPER::new(...);
bless $self, $class;
my $name = Gtk2::Entry->new();
$self->set_name("Test");
}
sub set_name {
my ($self, $fullname) = shift;
# this doesn't work
#$self->get_widget('name')->set_text($fullname);
}
Need more context, but i'll try to guess.
In general you just need to keep a handle to a widget if you're going
to use it elsewhere. Gtk2::GladeXML allows you to scrape the widget
tree for widgets by name with get_widget().
If you're building a window by hand and need to mess with the child
widgets, it's easy enough just to store a reference to the
interesting ones in some place you can get to later. E.g.:
sub new {
...
$self->{name_entry} = Gtk2::Entry->new;
...
}
sub set_name {
my ($self, $new_name) = @_;
$self->{name_entry}->set_text ($new_name);
}
--
Without treatment, a common cold will last about seven days.
With treatment, it will last about a week.
-- conventional wisdom
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list