#!/usr/bin/perl -w
use Tk;
$main = MainWindow->new();
$menubar = $main->Frame(-relief=>"raised",
-borderwidth=>2);
$filebutton = $menubar->Menubutton(-text=>"File",
-underline => 0); # F in File
$filemenu = $filebutton->Menu();
$filebutton->configure(-menu=>$filemenu);
$filemenu->command(-command => \&open_choice,
-label => "Open...",
-underline => 0); # O in Open
$filemenu->separator();
$filemenu->command(-label => "Exit",
-command => \&exit_choice,
-underline => 1); # "x" in Exit
$helpbutton = $menubar->Menubutton(-text=>"Help",
-underline => 0); # H in Help
$helpmenu = $helpbutton->Menu();
$helpmenu->command(-command => \&about_choice,
-label => "About TkMenu...",
-underline => 0); # A in About
$helpbutton->configure(-menu=>$helpmenu);
$filebutton->pack(-side=>"left");
$helpbutton->pack(-side=>"left");
$menubar->pack(-side=>"top", -fill=>"x");
$status = $main->Label(-text=>"Status area",
-relief=>"sunken",
-borderwidth=>2,
-anchor=>"w");
$status->pack(-side=>"top", -fill=>"x");
MainLoop();
sub exit_choice {
print "You chose the Exit choice!\n";
exit;
}
sub open_choice {
$status->configure(-text=>"Open file.");
print "Open file\n";
}
sub about_choice {
$status->configure(-text=>"About program.");
print "About tkmenu.pl\n";
}