Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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."


In reply to Aligning Tk Checkboxes by roho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-23 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found