widget name (was Re: Remove spaces in dialog window)
- From: muppet <scott asofyet org>
- To: Beast <beast i6x org>
- Cc: gtk-perl-list gnome org
- Subject: widget name (was Re: Remove spaces in dialog window)
- Date: Thu, 4 Aug 2005 08:26:43 -0400
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]