#!/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=>"right");
$menubar->pack(-side=>"top", -fill=>"x");
$label = $main->Label(-text => "Main Area");
$label->pack(-side=>"top",
-expand=>1,
-padx=>100,
-pady=>100);
MainLoop();
sub exit_choice {
print "You chose the Exit choice!\n";
exit;
}
sub open_choice {
print "Open file\n";
}
sub about_choice {
print "About tkmenu.pl\n";
}
|