sub setup_widgets {
my $main = new MainWindow;
my $quit = $main->Button(
'-text' => 'QUIT', '-command' => sub { exit });
$quit->pack('-fill' => 'x');
my $listbox = $main->Scrolled('Listbox' =>
'-scrollbars' => 'w', '-width' => $maxtitlelen,
'-height' => @{$db} > 5? 5: scalar @{$db},
);
$listbox->insert('end', @{$titles});
$listbox->bind('<Button-1>',
sub { select_record($listbox->index('anchor')) });
$listbox->pack('-fill' => 'both', '-expand' => 1);
foreach my $col (0..$maxcols-1) {
my $frame = $main->Frame();
my $label = $frame->Label(
'-text' => $fieldnames[$col],
'-width' => $maxfieldnamelen,
'-anchor' => 'w',
);
$label->pack('-side' => 'left');
my $field = $frame->Label(
'-textvariable' => \$fields[$col],
'-relief' => 'sunken',
'-width' => 50, '-anchor' => 'w',
);
$field->pack(
'-side' => 'left', '-fill' => 'x', '-expand' => 1);
$frame->pack('-fill' => 'x');
}
}
|