Thread Anfrage an die FAQ: Grundsätzliches TK-Problem (13 answers)
Opened by JW at 2007-05-18 01:52

Gast Gast
 2007-05-18 13:34
#46326 #46326
Hoi, hab dir das mal umgebaut, bin aber leider gerad in Eile und kann dir keine erklaerung dazu geben, sorry..

Code: (dl )
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);
}

View full thread Anfrage an die FAQ: Grundsätzliches TK-Problem