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

What is wrong with this code??? I reading O'Reilly's "Advanced perl Programming". I am trying to learn tk. I copied the program word for word and I get this error when it runs:
unknown option "width" at C:/Perl/site/lib/Tk/Widget.pm line 205. at C:\Documents and Settings\ssherman\Desktop\gui.pl line 20

# # # GUI TEST PROGRAM # # use Tk; # -------------------------------------------------------------------- +----- # Create a main window # -------------------------------------------------------------------- +----- $top = MainWindow->new(); $top->title ("Simple"); # -------------------------------------------------------------------- +----- # Instantiate widgets and arrange them # -------------------------------------------------------------------- +----- $l = $top->Label(text => 'hello', #label properties anchor => 'n', #anchor test to "north" relief => 'groove', #border style width => '10', height => '3');#10 chars wide, 3 high $l->pack(); # give it a default place within the main window # -------------------------------------------------------------------- +----- # Sit in an infinite loop dispathing incoming events. # -------------------------------------------------------------------- +----- MainLoop();

I also have ActiveState perl 5.8
I did try the dash, -width and that worked. I guess my question now is why can Aquarium run the program above with no problems and when I do it does work without the dash

Replies are listed 'Best First'.
Re: New to Perl TK
by zentara (Cardinal) on Jul 09, 2005 at 15:24 UTC
    There was some "tightening up of the Tk code" in version 804 vs version 800, where the underlying tcl version was upgraded. You will find that error in many old scripts, written for Tk800 when run on Tk804.027. It is a good habit to always prefix your option keys with a -.

    I'm not really a human, but I play one on earth. flash japh
Re: New to Perl TK
by kwaping (Priest) on Jul 09, 2005 at 14:28 UTC
    I haven't used Tk, but after reading Tk::Label, you might try prefixing your Label attribute keys with a dash (-). For example use -width instead of width.
Re: New to Perl TK
by aquarium (Curate) on Jul 09, 2005 at 14:19 UTC
    works for me. ran it on ActiveState perl 5.8
    the hardest line to type correctly is: stty erase ^H