programming-examples/perl/GUI/Build menu items for main windows.pl

29 lines
894 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
use Tk;
my $main = MainWindow->new();
$menubar = $main->Frame()->pack('-side' => 'top', '-fill' => 'x');
$filemenu = $menubar->Menubutton('-text' => 'File')->pack('-side' => 'left');
$filemenu->command('-label' => 'Open', '-command' => sub
{$text->delete('1.0', 'end');
$text->insert('end', "You clicked open.");});
$filemenu->separator();
$filemenu->command('-label' => 'Exit', '-command' => sub {exit});
$editmenu = $menubar->Menubutton('-text' => 'Edit')->pack('-side' => 'left');
$editmenu->command('-label' => 'Search', '-command' => sub
{$text->delete('1.0', 'end');
$text->insert('end', "You clicked search.");});
$editmenu->command('-label' => 'Replace', '-command' => sub
{$text->delete('1.0', 'end');
$text->insert('end', "You clicked replace.");});
$text = $main->Text ('-width' => 40, '-height' => 3)->pack();
MainLoop;