Here is a snippet I use as an example, posted long ago by some Tk programmer better than me at mega-widgets :-) I also would look at the pod for Tk::Derived for insight into mega-widgets and passing params. The big problem is how to get around the super widget rejecting params it dosn't handle. And check out Custom Widgets by Steven Lidie
#!/usr/bin/perl use warnings; use strict; package Tk::MyMega; use base qw/Tk::Frame/; use strict; Construct Tk::Widget 'MyMega'; sub Populate { my($self, $args) = @_; $self->SUPER::Populate($args); $self->{entry1} = $self->Entry->pack; $self->{entry2} = $self->Entry->pack; $self->ConfigSpecs( -variable1 => [qw/PASSIVE variable1 Variable1/, undef ], -variable2 => [qw/PASSIVE variable2 Variable2/, undef ], ); } # end Populate # an alternative #sub Populate { # my($self, $args) = @_; # # $self->SUPER::Populate($args); # # my $e1 = $self->Component(Entry => 'entry1')->pack; # my $e2 = $self->Component(Entry => 'entry2')->pack; # # $self->ConfigSpecs( # -variable1 => [{-textvariable => $e1}, qw/variable1 Variable1/], # -variable2 => [{-textvariable => $e2}, qw/variable2 Variable2/] #); #} sub ConfigChanged { my( $self, $args ) = @_; foreach my $k (keys %$args) { if( my( $n ) = $k =~ /^-variable(\d+)$/ ) { $self->{"entry${n}"}->configure( -textvariable => $args->{$k} ); } } } # end ConfigChanged package main; use Tk; #use Tk::MyMega; use strict; my $mw = MainWindow->new; my $frog = 1; my $toad = 2; my $mm = $mw->MyMega( -background => 'white', -foreground => 'blue', -variable1 => \$frog, -variable2 => \$toad, )->pack; $mw->update; $mw->after( 2000, sub{ $frog++; $toad++ } ); MainLoop;

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

In reply to Re: TK Mega Widget and User Edit by zentara
in thread TK Mega Widget and User Edit by PerlingTheUK

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.