in reply to how do I show 1 record at a time in Tk

Here's an example of something with  Yes/No buttons for user selection.

use warnings; use strict; use Tk; use Tk::LabFrame; use Tk::LabEntry; use constant MW => MainWindow->new( -title => 'pm#1208156', -padx => 45, ); # create all widgets and their children. my $entry_frame = MW->LabFrame( -label => 'Is This The One?', -labelside => 'acrosstop', -takefocus => 0, ); my @names = ( 'John Smith', 'Jane Doe', 'Francois Machin', 'Homer Simpson', ); my $candidate = 0; my $name = $names[$candidate]; my $entry = $entry_frame->LabEntry( -textvariable => \$name, -takefocus => 0, ); my $buttons_frame = MW->Frame; my $buttNo = $buttons_frame->Button( -text => 'No', -takefocus => 1, -command => sub { $candidate = ++$candidate % @names; $name = $names[$candidate]; }, ); my $selected_name = 'Uninitialized'; my $buttYes = $buttons_frame->Button( -text => 'Yes', -takefocus => 1, -command => sub { $selected_name = $name; MW->destroy; }, ); # pack all widgets. use constant STD_FRAME_PACK => qw(-expand 1 -fill x); use constant BUTT_PACK => STD_FRAME_PACK, qw(-side left -padx 10 -ipadx 5); $entry_frame->pack(STD_FRAME_PACK); $entry ->pack(STD_FRAME_PACK); $buttons_frame->pack(STD_FRAME_PACK); $buttNo ->pack(BUTT_PACK); $buttYes->pack(BUTT_PACK); $buttNo->focus; # set initial focus MainLoop; print "user selected <<$selected_name>> \n";

You may also be interested in Tk::BrowseEntry, described as "a poor man's ComboBox." This allows all possible selections to be displayed at once to a user in a scrollable list rather than presenting them one-by-one for selection.


Give a man a fish:  <%-{-{-{-<