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:  <%-{-{-{-<


In reply to Re: how do I show 1 record at a time in Tk by AnomalousMonk
in thread how do I show 1 record at a time in Tk by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.