#!/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=>\&getStartTime ); my $tab2 = $book->add( "Sheet 2", -label=>"Continue", -raisecmd=>\&getCurrentTime ); 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' ); } #### bad option "expand": must be -after, -anchor, -before, -expand, -fill, -in, -ipadx, -ipady, -padx, -pady, or -side at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Tk/Widget.pm line 1144. at NoteBook.pl line 18 #### # 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;