use strict;
use warnings;
use Tk;
my $top = MainWindow->new;
# use a frame widget as a container for menu buttons
my $menu_bar = $top->Frame->pack( side => 'top' );
# Search menu button
my $search_mb = $menu_bar->Menubutton(
text => 'Search',
relief => 'raised',
borderwidth => 2 )->pack(
side => 'left',
padx => 2 );
# Find menu buttons
$search_mb->command(
-label => 'Find',
accelerator => 'Meta+F',
underline => 0,
command => [\&whoami, 'Find'] );
$search_mb->command(
-label => 'Find Again',
accelerator => 'Meta+A',
underline => 0,
command => [\&whoami, 'Find Again' ] );
MainLoop();
sub whoami {
my $var = shift;
print $var;
}
Whenever you click on a menu option, the associated variable will be printed in the console window. This should give you some ideas.
Cheers,
Ovid
Vote for paco!
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. |