Re: How do I retrieve the 'type' of an object
- From: Ross McFarland <rwmcfa1 neces com>
- To: Gtk-Perl-List <gtk-perl-list gnome org>
- Subject: Re: How do I retrieve the 'type' of an object
- Date: Sun, 06 Jun 2004 21:42:32 -0400
On Sun, 2004-06-06 at 19:06, A. Pagaltzis wrote:
I'm not sure how much work would be involved for such an approach
with Gtk2-Perl though, since I've not subclassed/extended
anything yet, only used what was already there.
actually it's almost trivial you just need to be really careful that
whatever you name the method won't clash with some other (now or in the
future) method of Gtk2. package is the trick (not tested, but should be
about right):
my $btn = Gtk2::Button->new ('Click _Me');
my $label = Gtk2::Label->new ('Can't Click Me');
foreach ($btn, $label)
{
$_->my_method;
}
package Gtk2::Button
sub my_method
{
my $self = shift;
print 'button text: '.$self->get_label ()."\n";
}
package Gtk2::Label
sub my_method
{
my $self = shift;
print 'label text: '.$self->get_label ()."\n";
}
--
-rm
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]