I only used one text field here, but otherwise I think this what you want as a starting point:
#!/usr/bin/perl -W
use warnings 'all';
use strict;
use Tk::Pane;
my %data;
while (<DATA>) {
m/^(.)(.+?)\s+$/ and push @{ $data{"\u$1"} }, "\u$1\L$2";
}
my $mw = Tk::MainWindow->new();
my $left_pane = $mw->Scrolled(
'Pane',
-scrollbars => 'oe'
)->pack(
-expand => 'yes',
-fill => 'y',
-side => 'left',
);
my $right_pane = $mw->Scrolled(
'Pane',
-scrollbars => 'oe'
)->pack(
-expand => 'yes',
-fill => 'y',
-side => 'right',
);
my $middle_pane = $mw->Scrolled(
'Pane',
-scrollbars => 'oe'
)->pack(
-expand => 'yes',
-fill => 'x',
-side => 'top',
);
my $mid_entry = $middle_pane->Scrolled(
'Entry',
-relief => 'sunken',
-scrollbars => 's',
)->pack();
my @right_list;
sub alter_mid_and_right_panes {
my ($key,$value) = @_;
return unless $value; # Don't change when unchecking left box.
while( my $cb = pop @right_list ) {
$cb->destroy();
}
$mid_entry->delete(0, length($mid_entry->get()));
$mid_entry->insert(
'end',
"Ah, '$key'. What a great letter! I remember her well."
);
for my $word ( sort @{ $data{$key} } ) {
my $cb = $right_pane->Checkbutton(
-anchor => 'w',
-text => $word,
)->pack(
-side => 'top',
-fill => 'x',
);
push @right_list, $cb;
}
}
my @list;
for my $key ( sort keys %data ) {
my $value;
my $cb = $left_pane->Checkbutton(
-anchor => 'w',
-text => $key,
-variable => \$value,
-command => sub { alter_mid_and_right_panes($key, $value) },
)->pack(
-side => 'top',
-fill => 'x',
);
push @list, \$value;
}
Tk::MainLoop();
__DATA__
Abe
Apple
Baker
Bananna
|