One way to arrange things in 2 rows of 3 each is to divide your area into 2 Tk::Frames:
Red Green Blue | <-- Top frame |
Mustard Vinegar Salt | <-- Bottom frame |
Then pack each row into its frame, left-to-right:
my $mw = new Tk::MainWindow;
my $top = $mw->Frame->pack;
my $bottom = $mw->Frame->pack;
my @cb = ((map { $top->Checkbutton(-text => $_)->pack(-side => 'left')
+ }
qw{Red Green Blue}),
(map { $bottom->Checkbutton(-text => $_)->pack(-side => 'left')
+}
qw{Mustard Vinegar Salt}));
MainLoop;
Of course, this keeps the widths of different buttons independent. If you want everything nicely gridded out, use the Tk::grid geometry manager instead of Tk::pack. This lets you align everything, a bit like this:
Red | Green | Blue |
Mustard | Vinegar | Salt |
You'll probably want to stick each Checkbutton to the east side of its box, too:
my $mw = new Tk::MainWindow;
my @cb = ((map { $mw->Checkbutton(-text => (qw{Red Green Blue})[$_])->
grid(-column => $_, -row => 0, -sticky => 'w') } 0..2),
(map { $mw->Checkbutton(-text => (qw{Mustard Vinegar Salt})[$_])
+->
grid(-column => $_, -row => 1, -sticky => 'w') } 0..2));
MainLoop;
ariels -- Add table to explicate the thing with the grid.