Leser: 1
3 Einträge, 1 Seite |
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
# Hauptfenster
my $nw = MainWindow->new();
# Titel des Hauptfensters
$nw->title ('Man-Machine Interfaces II - UE - BSP 3');
# Menü
my $mbar = $nw -> Menu();
$nw->configure (-menu => $mbar);
my $file = $mbar->cascade (-label => "File", -underline => 0, -tearoff => 0);
$file->command (-label => "Exit", -command => [$nw => 'destroy']);
# Frames
my $f1 = $nw->Frame()->pack (-side => 'top', -expand => 1, -fill => 'both');
my $f2 = $nw->Frame()->pack (-side => 'left', -expand => 1, -fill => 'both');
my $f3 = $nw->Frame()->pack (-side => 'bottom', -expand => 1, -fill => 'both');
# Buttons
my $b1 = $f1->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'top', -expand => 1, -fill => 'both');
my @buttonwahl1 = ('1', '2', '3');
for my $a (0..$#buttonwahl1)
{
$b1->Button (-text => $buttonwahl1[$a], -command => sub {print "$buttonwahl1[$a]"})->pack (-anchor => 'e');
}
my $b2 = $f2->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'left', -expand => 1, -fill => 'both');
my @buttonwahl2 = ('4', '5', '6');
for my $b (0..$#buttonwahl2)
{
$b2->Button (-text => $buttonwahl2[$b], -command => sub {print "$buttonwahl2[$b]"})->pack (-anchor => 'e');
}
my $b3 = $f3->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'bottom', -expand => 1, -fill => 'both');
my @buttonwahl3 = ('7', '8', '9', '0');
for my $c (0..$#buttonwahl3)
{
$b3->Button (-text => $buttonwahl3[$c], -command => sub {print "$buttonwahl3[$c]"})->pack (-anchor => 'e');
}
MainLoop();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use Tk;
$top = tkinit;
# Gitter erzeugen
for (1..9) {
$top->Label(-text => $_)->grid(-row => ($_-1)/3,
-column => ($_-1)%3,
);
}
$top->Label(-text => "0")->grid(-row => 3, -column => 1);
# Gleiche Breiten und Höhen erzwingen:
for (0..2) {
$top->gridColumnconfigure($_, -weight => 1, -uniform => 1);
}
for (0..3) {
$top->gridRowconfigure($_, -weight => 1, -uniform => 1);
}
MainLoop;
3 Einträge, 1 Seite |