Debian Codegraph @

examples/sillymenu

raw
1 #!/usr/local/bin/perl -w
2 use strict;
3 use Tk;
4 use Data::Dumper;
5
6 my $mw = MainWindow->new;
7 my $menu = $mw->Menu;
8 for my $i (1..24)
9 {
10 my $sm = $menu->cascade(-label => "Button$i");
11 $sm->command(-label => 'Quit', -command => \&lrw);
12 }
13 my $h = $menu->cascade(-label => "Help");
14 $h->command(-label => 'Quit', -command => [destroy => $mw]);
15
16 $mw->configure(-menu => $menu);
17 $mw->Scrolled('Text')->pack(-fill => 'both', -expand => 1);
18 $mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
19
20 MainLoop;
21
22 sub lrw
23 {
24 my $menu = $mw->Menu;
25 my $h = $menu->cascade(-label => "Help");
26 $h->command(-label => 'Quit', -command => [destroy => $mw]);
27 for my $i (1..5)
28 {
29 my $sm = $menu->cascade(-label => "Left$i");
30 $sm->command(-label => 'Quit', -command => [destroy => $mw]);
31 }
32 $menu->separator;
33 for my $i (1..5)
34 {
35 my $sm = $menu->cascade(-label => "Right$i");
36 $sm->command(-label => 'Quit', -command => [destroy => $mw]);
37 }
38 $mw->configure(-menu => $menu);
39 }