|< 1 2 >| | 14 Einträge, 2 Seiten |
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
52
53
54
55
56
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
# Hauptfenster
my $nw = MainWindow->new();
# Titel
$nw->title ('Man-Machine Interfaces II - UE - BSP 1');
# Menü
my $mb = $nw->Frame (-relief => 'ridge')->pack (-side => 'top', -fill => 'x');
my $m_file = $mb->Menubutton (-text => "File", -underline => 0)->pack (-side => 'left');
$m_file->command (-label => "Activate", -command => sub {activate()});
$m_file->separator();
$m_file->command (-label => "Quit", -command => [$nw => 'destroy']);
# Frames
my $f1 = $nw->Frame()->pack (-side => 'top', -expand => 1, -fill => 'both');
my $f2 = $nw->Frame()->pack (-side => 'bottom', -expand => 1, -fill => 'both');
# Radiobuttons
my $r1 = $f1->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'left', -expand => 1, -fill => 'both');
my @listenwahl = ('1', '2', '3');
my $liste = 0;
for my $a (0..$#listenwahl)
{
$r1->Radiobutton (-text => $listenwahl[$a], -variable => \$liste, -value => $a)->pack (-anchor => 'e');
}
my $r2 = $f1->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'left', -expand => 1, -fill => 'both');
my @textwahl = ('normal', 'rückwärts');
my $text = 0;
for my $b (0..$#textwahl)
{
$r2->Radiobutton (-text => $textwahl[$b], -variable => \$text, -value => $b)->pack (-anchor => 'w');
}
# Entries
my $entry1 = $nw->Entry (-text => "Das ist ein Satz!")->pack (-side => 'top');
my $entry2 = $nw->Entry (-text => "!ztaS nie tsi saD");
# Listboxen und Scrollbars
my $listbox1 = $f2->Listbox()->pack (-side => 'left', -expand => 1, -fill => 'both');
my $scrollbar1 = $f2->Scrollbar(-command, [yview => $listbox1])->pack (-side => 'left', -expand => 1, -fill => 'both');
my $listbox2 = $f2->Listbox()->pack (-side => 'left', -expand => 1, -fill => 'both');
my $scrollbar2 = $f2->Scrollbar(-command, [yview => $listbox2])->pack (-side => 'left', -expand => 1, -fill => 'both');
my $listbox3 = $f2->Listbox()->pack (-side => 'left', -expand => 1, -fill => 'both');
my $scrollbar3 = $f2->Scrollbar(-command, [yview => $listbox3])->pack (-side => 'left', -expand => 1, -fill => 'both');
MainLoop();
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
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
# Hauptfenster
my $nw = MainWindow->new();
# Titel
$nw->title ('Man-Machine Interfaces II - UE - BSP 1');
# Menü
my $mb = $nw->Frame (-relief => 'ridge')->pack (-side => 'top', -fill => 'x');
my @listboxes;
my $liste = 0;
my $m_file = $mb->Menubutton (-text => "File", -underline => 0)->pack (-side => 'left');
$m_file->command (-label => "Activate", -command => sub {activate($liste,\@listboxes)});
$m_file->separator();
$m_file->command (-label => "Quit", -command => [$nw => 'destroy']);
# Frames
my $f1 = $nw->Frame()->pack (-side => 'top', -expand => 1, -fill => 'both');
my $f2 = $nw->Frame()->pack (-side => 'bottom', -expand => 1, -fill => 'both');
# Radiobuttons
my $r1 = $f1->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'left', -expand => 1, -fill => 'both');
my @listenwahl = ('1', '2', '3');
for my $a (0..$#listenwahl)
{
$r1->Radiobutton (-text => $listenwahl[$a], -variable => \$liste, -value => $a)->pack (-anchor => 'e');
}
my $r2 = $f1->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'left', -expand => 1, -fill => 'both');
my @textwahl = ('normal', 'rückwärts');
my $text = 0;
for my $b (0..$#textwahl)
{
$r2->Radiobutton (-text => $textwahl[$b], -variable => \$text, -value => $textwahl[$b])->pack (-anchor => 'w');
}
# Entries
my $entry1 = $nw->Entry (-text => "Das ist ein Satz!")->pack (-side => 'top');
my $entry2 = $nw->Entry (-text => "!ztaS nie tsi saD");
for (0..2) {
push(@listboxes, $f2->Listbox()->pack (-side => 'left', -expand => 1, -fill => 'both'));
$f2->Scrollbar(-command, [yview => $listboxes[$_]])->pack (-side => 'left', -expand => 1, -fill => 'both');
}
MainLoop();
sub activate {
my ($liste, $listbox_ref) = @_;
print "$liste\n";
print join("\n", @$listbox_ref)."\n";
my $string = $entry1->get();
my @string = reverse split//,$string;
$string = reverse($string) if ($text eq 'rückwärts');
@$listbox_ref[$liste]->insert('0.0', $string);
}
1
2
3
4
5
6
7
8
sub activate {
my ($liste, $listbox_ref) = @_;
my $string = $entry1->get();
$string = reverse($string) if ($text eq 'rückwärts');
my @string = split/ /, $string;
@$listbox_ref[$liste]->insert('end', "$_") for (@string);
}
$listbox->delete(index1,index2)
$listbox->deleteAll();
|< 1 2 >| | 14 Einträge, 2 Seiten |