Leser: 4
9 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
my $datei = $menubar->cascade(-label => '~Datei',
-tearoff => 0);
$datei->command(-label => 'Neu', -command => \&neu);
$datei->command(-label => 'Öffnen...', -command => \&open);
$datei->command(-label => 'Speichern', -command => \&speichern);
$datei->command(-label => 'Speichern unter...', -command => \&speichernunter);
$datei->separator();
$datei->command(-label => 'Beenden', -command => [$mw=>'destroy']);
\$test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/perl -w use strict; use Tk; my $test = 123; my $mw = tkinit(); my $l1 = $mw->Label(-text => $test)->pack(); $mw->Button(-command => sub {chg_txt(\$test)} )->pack; MainLoop; sub chg_txt { my $test = shift; $$test = 'Testtext2'; $mw->update(); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
my $mw = MainWindow->new(-title=>"Test");
my $toplevel = $mw->toplevel;
my $n = 'Neu';
my $o = 'Öffnen..';
my $s = 'Speichern';
my $sp = 'Speichern unter...';
my $b = 'Beenden';
our $menubar;
Menu($n,$o,$s,$sp,$b);
sub Menu{
my $n = shift;
my $o = shift;
my $s = shift;
my $sp = shift;
my $b = shift;
$menubar = $toplevel->Menu(-type => 'menubar');
$toplevel->configure(-menu => $menubar);
my $datei = $menubar->cascade(-label => '~Datei',
-tearoff => 0);
$datei->command(-label => "$n", -command => \&neu);
$datei->command(-label => "$o", -command => \&open);
$datei->command(-label => "$s", -command => \&speichern);
$datei->command(-label => "$sp", -command => \&speichernunter);
$datei->separator();
$datei->command(-label => "$b", -command => [$mw=>'destroy']);
}
$mw->Button(-text=>'clear',-command => sub {&chance} )->pack;
MainLoop;
sub chance {
$menubar->destroy;
my $n = 'new';
my $o = 'open';
my $s = 'save';
my $sp = 'save as';
my $b = 'close';
Menu($n,$o,$s,$sp,$b);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new(-title=>"Test"); my $toplevel = $mw->toplevel; my $menubar = $toplevel->Menu(-type => 'menubar'); $toplevel->configure(-menu => $menubar); my $datei = $menubar->cascade(-label => '~Datei', -tearoff => 0); my $n = $datei->command(-label => 'Neu', -command => \&neu); my $o = $datei->command(-label => 'Öffnen', -command => \&open); $mw->Button(-text=>'Change Text',-command => sub {&change_text} )->pack; MainLoop; sub change_text { $n->configure(-label => 'New'); $o->configure(-label => 'Open'); }
9 Einträge, 1 Seite |