See the NOTE comments for possible solutions to some of your n) issues.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11142273 use warnings; use Tk; my $additionalcheckbutton = 0; my @checkbuttonlabels = split /\n/, <<END; one two very long text entry for test purposes three for more info align problem four extra check END my @values = (0) x @checkbuttonlabels; my $wantspecial = 0; my $notes; my $mw = MainWindow->new; $mw->geometry('+700+400'); $mw->Button(-text => 'Exit', -command => sub{$mw->destroy}, )->pack(-side => 'bottom', -fill => 'x'); my $leftframe = $mw->Frame()->pack(-side => 'left'); my $n = 0; my @cbs = map { $leftframe->Checkbutton( -text => s/.{20}\K /\n/gr, # NOTE 1a) wrap if text too long -anchor => 'w', # NOTE 1) align buttons with -fill x -variable => \$values[$n++], -command => \&addextra, )->pack(-fill => 'x'); } @checkbuttonlabels; $mw->Frame(-bg => 'blue', -width => 3, # NOTE 2) separation line )->pack(-side => 'left', -fill => 'y'); my $rightframe = $mw->Frame()->pack(-side => 'left'); $rightframe->Label(-text => "The Right Side\nFrame", )->pack; $rightframe->Checkbutton(-text => "Special Notes?", -variable => \$wantspecial, -command => \&specialnotes, )->pack; my $subframe = $rightframe->Frame->pack; $subframe->Label(-text => 'Special Notes', -bg => 'blue', -fg => 'whit +e',, )->pack(-fill => 'x'); $notes = $subframe->Text()->pack; $_->packForget for @cbs[4, -1], $subframe; # NOTE initially not visibl +e MainLoop; -M $0 < 0 and exec $0; # for testing FIXME sub specialnotes # pack/packForget special notes { if( $wantspecial ) { $subframe->pack; $notes->delete('1.0' => 'end'); } else { $subframe->packForget; } } sub addextra { # NOTE 3) add additional checkbox $additionalcheckbutton++ or $cbs[-1]->pack(-fill => 'x'); if( $values[3] ) # NOTE 6) addextra for checkbutton three { $cbs[4]->pack(-fill => 'x', -after => $cbs[3] ); } else { $cbs[4]->packForget; } }

Uses pack/packForget for widgets that are transitory.


In reply to Re: Perl Tk, how to get File Browser, capture output to a Log file and format my checkboxes by tybalt89
in thread Perl Tk, how to get File Browser, capture output to a Log file and format my checkboxes by perlynewby

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.