Hi Monks,
I was reading the article
Using advanced widgets in Perl/Tk, and following along with the exercices. The first example given is on using the NoteBook widget.
(code sligthly adapted with use strict and warnings)
#!/usr/bin/perl -w
+
use strict;
use Tk;
use Tk::NoteBook;
+
my $mw = MainWindow->new();
$mw->geometry( "400x100" );
my $book = $mw->NoteBook()->pack( -fill=>'both', -expand=>1 );
+
my $tab1 = $book->add( "Sheet 1", -label=>"Start", -createcmd=>\&getSt
+artTime );
my $tab2 = $book->add( "Sheet 2", -label=>"Continue", -raisecmd=>\&get
+CurrentTime );
my $tab3 = $book->add( "Sheet 3", -label=>"End", -state=>'disabled' );
+
my $starttime = '';
my $raisetime = '';
+
$tab1->Label( -textvariable=>\$starttime )->pack( expand=>1 );
$tab2->Label( -textvariable=>\$raisetime )->pack( expand=>1 );
$tab3->Button( -text=>'Quit', -command=>sub{ exit; } )->pack( expand=>
+1 );
+
MainLoop;
+
sub getStartTime {
$starttime = "Started at " . localtime;
}
sub getCurrentTime {
$raisetime = " Last raised at " . localtime;
$book->pageconfigure( "Sheet 3", -state=>'normal' );
}
When I execute this program, I get the error message:
bad option "expand": must be -after, -anchor, -before, -expand, -fill,
+ -in, -ipadx, -ipady, -padx, -pady, or -side at /usr/lib/perl5/site_p
+erl/5.8.0/i386-linux-thread-multi/Tk/Widget.pm line 1144.
at NoteBook.pl line 18
The relevant part in Widget.pm is:
# Two things going on here:
# 1. Add configure on the front so that we can drop leading '-'
$w->Tk::pack('configure',@_);
# 2. Return the widget rather than nothing
return $w;
I don't feel much like meddling in Widget.pm self, but what else should I do?