in reply to TK Mega Widget and User Edit

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