http://www.perlmonks.org?node_id=993582


in reply to Re^3: Aligning Tk Checkboxes
in thread Aligning Tk Checkboxes

Thanks zentara. The Tk::CheckbuttonGroup module works great! It looks like the synopsis code was missing "pack". Unfortunately, I just found out I'm not going to be able to install additional CPAN modules at deployment sites (sigh), so (taking a cue from the module) I re-worked the frames in my original code to display two vertically aligned columns of checkboxes using only Tk (see new code below). Thanks for all your help.

#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new(); $mw->geometry('360x250+280+60'); $mw->bind('<Escape>' => sub {exit;}); $mw->configure(-title => 'Test Checkbox Alignment'); my ($qv, $dg, $yb, $pv, $rd, $oc, $hr, $tm); ################################################################### # Create buffer 1. ################################################################### my $buffer1 = $mw->Frame; $buffer1->pack(-side => 'left', -padx => 25); ################################################################### # Create frame 1. ################################################################### my $frame1 = $mw->Frame; $frame1->pack(-side => 'left'); ################################################################### # Create check box 1 for frame 1. ################################################################### my $qv_cbox = $frame1->Checkbutton( -text => 'QuickCheck', -variable => \$qv, ); $qv_cbox->pack( -side => 'top', -anchor => 'w', ); ################################################################### # Create check box 2 for frame 1. ################################################################### my $dg_cbox = $frame1->Checkbutton( -text => 'Systems Guide', -variable => \$dg, ); $dg_cbox->pack( -side => 'top', -anchor => 'w', ); ################################################################### # Create check box 3 for frame 1. ################################################################### my $yb_cbox = $frame1->Checkbutton( -text => 'Study', -variable => \$yb, ); $yb_cbox->pack( -side => 'top', -anchor => 'w', ); ################################################################### # Create check box 4 for frame 1. ################################################################### my $pv_cbox = $frame1->Checkbutton( -text => 'Analyze', -variable => \$pv, ); $pv_cbox->pack( -side => 'top', -anchor => 'w', ); ################################################################### # Create buffer 2. ################################################################### my $buffer2 = $mw->Frame; $buffer2->pack(-side => 'left', -padx => 25); ################################################################### # Create frame 2. ################################################################### my $frame2 = $mw->Frame; $frame2->pack(-side => 'left'); ################################################################### # Create check box 1 for frame 2. ################################################################### my $rd_cbox = $frame2->Checkbutton( -text => 'Read', -variable => \$rd, ); $rd_cbox->pack( -side => 'top', -anchor => 'w', ); ################################################################### # Create check box 2 for frame 2. ################################################################### my $oc_cbox = $frame2->Checkbutton( -text => 'Configure', -variable => \$oc, ); $oc_cbox->pack( -side => 'top', -anchor => 'w', ); ################################################################### # Create check box 3 for frame 2. ################################################################### my $hr_cbox = $frame2->Checkbutton( -text => 'Troubleshoot', -variable => \$hr, ); $hr_cbox->pack( -side => 'top', -anchor => 'w', ); ################################################################### # Create check box 4 for frame 2. ################################################################### my $tm_cbox = $frame2->Checkbutton( -text => 'Prioritize', -variable => \$tm, ); $tm_cbox->pack( -side => 'top', -anchor => 'w', ); MainLoop; exit;

"Its not how hard you work, its how much you get done."