PerlingTheUK has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am currently creating a user Interface, where several Dialogs include the same Frame.
I do not want to just create a Frame and a Button but try to derive it properly from the Frame class, in a style tzpical for TK.
I am aware that I need to inherit from Derived and Frame, but I do not really understand the "standards" of the TK files. Is there something like a manual around defining rules how to do this?

Cherrs for any answers.
Hans

Replies are listed 'Best First'.
Re: Deriving Perl TK
by zentara (Cardinal) on Jun 30, 2004 at 18:08 UTC
    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
      Also check the Tk::mega manpage for more information.