Hi, I'm trying to (learn how to) create a mega-widget in Perl/Tk and am hacking some examples from "Mastering Perl/Tk". I apparently do not understand how to use ConfigSpecs. I'm trying to be able to pass arguments to the widget constructor and define default values if the arguments are not specified. But no luck ...
Any suggestions / explanations as to why the following does not do what I'm hoping for? --------------------------------------------------------- package Tk::Nil; # 1 use base qw/Tk::Toplevel/; # 2 Construct Tk::Widget 'Nil'; # 3 sub Populate { my($self, $args) = @_; $self->SUPER::Populate($args); my $msg = $self->cget(-arg) ? "arg passed" : "arg NOT passed"; $self->Label(-text => $msg)->pack(qw/-expand 1 -fill both/); $self->ConfigSpecs( -arg => ['PASSIVE', undef, undef, 0], ); } # end Populate package main; use Tk; use strict; my $mw = MainWindow->new(-title => 'Nil MW'); my $nil = $mw->Nil(-title => 'Nil object', -arg => 1); $nil->configure(-background => '#d9d9d9'); print '-background = ', $nil->cget(-background), "\n"; $mw->update; MainLoop; ------------------------------------- Thanks, Cort