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

Hi Brother Marshall

Thank you for that, I am beginning to understand sort of how the hierachy works...so Frames can take subFrames and scrolling listboxes in them...I need a scrolling structure (Frame,Pane, Whatever) to take multiple rows of Checkbuttons which behave as a scrlled item behaves...without leaking out of the parent Frame/Pane etc. But I will try and do as you say. Thank you.

  • Comment on Re^4: TK Placing Widgets in a Scrolling Pane

Replies are listed 'Best First'.
Re^5: TK Placing Widgets in a Scrolling Pane
by kcott (Archbishop) on Dec 05, 2021 at 09:35 UTC

    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