Something like this?

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11163804 use warnings; use Tk; use Data::Dump qw( pp ); my %IdxToNickName = qw( a one b two c three ); my %IdxToNickNameSel; my $main = MainWindow->new; # Set up frames to contain all the pids (for selection) $main->Label(-text => 'Below are the CheckButtons', -bg => 'green', )->pack(-fill => 'x'); my $frame_pids; $frame_pids = $main->Frame(-borderwidth => 2, -relief => 'groove'); $frame_pids->pack; $main->Label(-text => 'Below is a Text widget', -bg => 'green', )->pack(-fill => 'x'); my $edit = $main->Text()->pack; $main->Label(-text => 'Below is a grid of Labels', -bg => 'green', )->pack(-fill => 'x'); my $labelframe = $main->Frame->pack; my @sortedKeys = ( sort keys %IdxToNickName ); my $row = 1; for my $k (@sortedKeys) { my $pid_nickname = $IdxToNickName{$k}; my $cb = $frame_pids->Checkbutton( -text => sprintf("%-15s",$pid_nickname), # courier and -15 implies fixed length left justifi +ed -variable => \$IdxToNickNameSel{$k}, # this is a hash for the selection result (so other +s can access) -font => ['courier', 10, 'bold'], # and a font size -command => \&showtext, ); $IdxToNickNameSel{$k} = 0; # Initialise the selection to 0 $cb->pack(-side => 'top'); # Pack the cb according to left c +riteria $labelframe->Label(-text => $IdxToNickName{$k}, )->grid(-row => $row, -column => 1, -sticky => 'e'); $labelframe->Label(-textvariable => \$IdxToNickNameSel{$k}, )->grid(-row => $row, -column => 2); $row++ } $main->Button(-text => 'Exit', -command => sub{$main->destroy}, -bg => 'red', -fg => 'white', )->pack(-fill => 'x'); showtext(); MainLoop; sub showtext { $edit->Contents( pp \%IdxToNickNameSel ) }

In reply to Re: Perl Tk module; optional select to result presentation by tybalt89
in thread Perl Tk module; optional select to result presentation by jmClifford

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.