in reply to Deriving Perl TK

The book Mastering Perl/Tk has a chapter on Customizing Widgets. If you are in a hurry you can get a download of it from Safari.

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;

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Deriving Perl TK
by eserte (Deacon) on Jul 02, 2004 at 18:17 UTC
    Also check the Tk::mega manpage for more information.