Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Bad option in Widget.pm

by BioGeek (Hermit)
on Apr 13, 2005 at 16:33 UTC ( [id://447490]=perlquestion: print w/replies, xml ) Need Help??

BioGeek has asked for the wisdom of the Perl Monks concerning the following question:

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?

Replies are listed 'Best First'.
Re: Bad option in Widget.pm
by shenme (Priest) on Apr 13, 2005 at 16:50 UTC
    But you show yourself using the wrong option "expand" rather than "-expand":
    $tab1->Label( -textvariable=>\$starttime )->pack( expand=>1 ); $tab2->Label( -textvariable=>\$raisetime )->pack( expand=>1 ); $tab3->Button( -text=>'Quit', -command=>sub{ exit; } )->pack( expand=> +1 );
    Isn't that what the error message was referring to?
      Indeed, that was the culprit. I thougth that if the code was featured in a tutorial on an IBM-site, that it would be tested and flawless, but... apparently not.
        I thougth that if the code was featured in a tutorial on an IBM-site, that it would be tested and flawless

        The change to require the '-' in front of options, occured when PerlTk upgraded to the latest TCL base. So the old PerlTk was versioned with 800 numbers, while the current version is series 804.

        So the code does run flawlessly on the Tk version, on which it was written ..Tk800.xxx. There are many old Tk scripts like that floating around. Just go to the snippets and code sections of perlmonks and look for old Tk snippets from a few years ago. They will all give those errors if you try and run them on Tk804.xxx. It's simple to fix the scripts.

        The same is true of Gtk2 scripts..the libraries are always being improved, and sometimes it breaks "old syntax".


        I'm not really a human, but I play one on earth. flash japh
        warn("err is human"x 2)'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://447490]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-24 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found