in reply to Deriving Perl TK
Also you can check out perldoc Tk::Derived. Here is an example:
#!/usr/bin/perl use Tk; use strict; package MyButton; use base qw/Tk::Derived Tk::Button/; Construct Tk::Widget 'MyButton'; sub ClassInit { my ($class, $mw) = @_; $class->SUPER::ClassInit($mw); } sub Populate { my ($self, $args) = @_; $self->SUPER::Populate($args); $self->bind('<Enter>', sub{print "Entered a MyButton\n"}); } 1; package main; my $mw = MainWindow->new; $mw->Button(-text => 'NormalButton')->pack; $mw->MyButton(-text => 'MyButton')->pack; MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Deriving Perl TK
by eserte (Deacon) on Jul 02, 2004 at 18:17 UTC |