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.