in reply to Re^4: TK Placing Widgets in a Scrolling Pane
in thread TK Placing Widgets in a Scrolling Pane

Try this:

#!/usr/bin/env perl use strict; use warnings; use constant { LIST_W => 28, LIST_H => 14, LIST_X => 50, LIST_Y => 12, }; use Tk; use Tk::HList; my $mw = MainWindow->new; $mw->geometry('400x250'); my $hlist_F = $mw->Frame()->pack(qw{-expand 1 -fill both}); my $hlist_scrl = $hlist_F->Scrolled(HList => -scrollbars => 'osoe', -columns => 1, -header => 0, -itemtype => 'window', -width => LIST_W, -height => LIST_H, )->pack( -fill => 'y', -side => 'left', -anchor => 'n', -padx => LIST_X, -pady => LIST_Y, -ipadx => 5, -ipady => 5, ); my $hlist = $hlist_scrl->Subwidget('scrolled'); my @colours = qw{ red green blue yellow cyan magenta orange teal purple pink lime azure rose olive lilac black grey white gold silver bronze }; my (%palette, @cboxes); for (@colours) { $palette{$_}{val} = 0; $palette{$_}{cb} = $hlist->Checkbutton( -text => $_, -variable => \$palette{$_}{val}, -anchor => 'w', -pady => 0, ); push @cboxes, $palette{$_}{cb}; } $hlist->add("$_", -widget => $_) for @cboxes; MainLoop();

I believe it covers all the bits that you want.

— Ken