roho has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to left align 4 sets of checkboxes in Tk. I have extracted the part of my program that builds the checkboxes. I am packing them to the left and anchoring them west, but the checkboxes are anything but aligned. I tried creating a frame for each of the 4 sets of checkboxes, but that did not help. Please note that I am building the sets of checkboxes from the bottom of the screen up, which should not matter as far as alignment goes. I'm sure that I'm missing somehting very simple here. How can I get the checkboxes to align regardless of the text that follows them? Thanks.
#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = new MainWindow; $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 frame for 4th set of check boxes. ################################################################### my $frame_cb0 = $mw->Frame; $frame_cb0->pack(-side => "bottom", -pady => 1); ################################################################### # Create first check box for 4th set. ################################################################### my $qv_cbox = $frame_cb0->Checkbutton( -text => 'QuickCheck', -variable => \$qv, ); $qv_cbox->pack( -side => "left", -anchor => 'w', ); ################################################################### # Create second check box for 4th set. ################################################################### my $dg_cbox = $frame_cb0->Checkbutton( -text => 'Systems Guide', -variable => \$dg, ); $dg_cbox->pack( -side => "left", -anchor => 'w', ); ################################################################### # Create frame for 3rd set of check boxes. ################################################################### my $frame_cb1 = $mw->Frame; $frame_cb1->pack(-side => "bottom", -pady => 1); ################################################################### # Create first check box for 3rd set. ################################################################### my $yb_cbox = $frame_cb1->Checkbutton( -text => 'Study', -variable => \$yb, ); $yb_cbox->pack( -side => "left", -anchor => 'w', ); ################################################################### # Create second check box for 3rd set. ################################################################### my $pv_cbox = $frame_cb1->Checkbutton( -text => 'Analyze', -variable => \$pv, ); $pv_cbox->pack( -side => "left", -anchor => 'w', ); ################################################################### # Create frame for 2nd set of check boxes. ################################################################### my $frame_cb2 = $mw->Frame; $frame_cb2->pack(-side => "bottom", -pady => 1); ################################################################### # Create first check box for 2nd set. ################################################################### my $rd_cbox = $frame_cb2->Checkbutton( -text => 'Read', -variable => \$rd, ); $rd_cbox->pack( -side => "left", -anchor => 'w', ); ################################################################### # Create second check box for 2nd set. ################################################################### my $oc_cbox = $frame_cb2->Checkbutton( -text => 'Configure', -variable => \$oc, ); $oc_cbox->pack( -side => "left", -anchor => 'w', ); ################################################################### # Create frame for 1st set of check boxes. ################################################################### my $frame_cb3 = $mw->Frame; $frame_cb3->pack(-side => "bottom", -pady => 1); ################################################################### # Create first check box for 1st set. ################################################################### my $hr_cbox = $frame_cb3->Checkbutton( -text => 'Troubleshoot', -variable => \$hr, ); $hr_cbox->pack( -side => "left", -anchor => 'w', ); ################################################################### # Create second check box for 1st set. ################################################################### my $tm_cbox = $frame_cb3->Checkbutton( -text => 'Prioritize', -variable => \$tm, ); $tm_cbox->pack( -side => "left", -anchor => 'w', ); MainLoop; exit;
"Its not how hard you work, its how much you get done."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Aligning Tk Checkboxes
by protist (Monk) on Sep 13, 2012 at 02:26 UTC | |
by kcott (Archbishop) on Sep 13, 2012 at 03:13 UTC | |
by stefbv (Curate) on Sep 13, 2012 at 07:55 UTC | |
by protist (Monk) on Sep 13, 2012 at 16:12 UTC | |
by kcott (Archbishop) on Sep 14, 2012 at 05:44 UTC | |
Re: Aligning Tk Checkboxes
by zentara (Archbishop) on Sep 13, 2012 at 10:56 UTC | |
by roho (Bishop) on Sep 13, 2012 at 15:01 UTC | |
by zentara (Archbishop) on Sep 13, 2012 at 17:10 UTC | |
by roho (Bishop) on Sep 13, 2012 at 21:20 UTC | |
Re: Aligning Tk Checkboxes
by kcott (Archbishop) on Sep 13, 2012 at 03:02 UTC |
Back to
Seekers of Perl Wisdom