http://www.perlmonks.org?node_id=108853

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

I feel really stupid asking this. My apologies in advance.

I'm working through the Perl/Tk chapters in O'Reilly's Advanced Perl Programming. I typed in the menu example verbatum minus comments and with only one button (included below) and I get this error:

No -label at /usr/lib/perl5/site_perl/5.005/i586-linux/Tk/Widget.pm line 247

The perldocs for Tk::Menubutton, Tk::options, Tk::Menu, and Tk::Widget don't make any reference to a label option in any way that I can find meaningful.

Is there some other distro of Perl/Tk that I should be using? How can I tell?

elbieelbieelbie

use Tk; $top = MainWindow->new(); $menu_bar = $top->Frame()->pack(side => 'top'); $search_mb = $menu_bar->Menubutton(text => 'Search', relief => 'raised', borderwidth => 2 )->pack(side => 'left', padx => 2 ); $search_mb->command(label => 'Find', accelerator => 'Meta+F', underline => 0, command => sub {print "find\n"} ); MainLoop();

Replies are listed 'Best First'.
(jeffa) Re: Problem following Tk demo in Advanced Perl Programming
by jeffa (Bishop) on Aug 30, 2001 at 00:00 UTC
    change label to -lable

    :)

    Another reference (sic) to check out is Learning Perl Tk.

    Big whoops! - thanks Graham! yes, -label

    jefaf

      Surely that should read "-label" So that the entire script is
      use Tk; $top = MainWindow->new(); $menu_bar = $top->Frame()->pack(side => 'top'); $search_mb = $menu_bar->Menubutton(text => 'Search', relief => 'raised', borderwidth => 2 )->pack(side => 'left', padx => 2 ); $search_mb->command(-label => 'Find', accelerator => 'Meta+F', underline => 0, command => sub {print "find\n"} ); MainLoop();