Hi, I just came accross this by Stephen Lidie about creating a mega-widget, hope it helps. It uses Tk::Derived .
#Stephen Lidie wrote: #There are at least two ways of doing it: ferreting out the actual #superclass callback and invoking it manually (not recommended), or #creating a proper mega-widget. The mega-widget method is cleaner and + #seems to do what you want. #Here is a modified version of the Emu example. First, note that I #added Tk::Derived to the module's base class because we need to turn + #this into a first class mega-widget - it's no longer a simple example +. #Second, the <Enter> binding has been deleted from the class #initialization method ClassInit(). ------------------------------------------------------------- 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); # $mw->bind($class, '<Enter>', sub{print "Entered a MyButton\n"}); } sub Populate { my ($self, $args) = @_; $self->SUPER::Populate($args); $self->bind('<Enter>', sub{print "Entered a MyButton\n"}); # my (@bt) = $self->bindtags; # $self->bindtags( [ @bt[ 1, 0, 2, 3 ] ] ); } 1; package main; my $mw = MainWindow->new; $mw->Button(-text => 'NormalButton')->pack; $mw->MyButton(-text => 'MyButton')->pack; MainLoop; #-------------------------------------------------------------- #The real change is the addition of Populate(), the class instance #constructor. It's responsible for creating the <Enter> binding. Now + #when you <Enter> a MyButton mega-widget it behaves exactly as a norma +l #Button does, plus, it prints a message.

In reply to Re: Tk::widgets ConfigDefault not working? by zentara
in thread Tk::widgets ConfigDefault not working? by jpream

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.