First, let me say that this is only the third or fourth Tk script I've fooled with so this is as much a learning process for me as it is you (if not moreso). I've tried this little script and I think it has the elements you've described. The only problem is that although it looks right, it doesn't scroll. So maybe you can use this as a starting point and do some research from there. I'll keep working on it as well, and hopefully one of us or some more experienced and merciful monk will figure it out.
use strict; use Tk; my $mw = MainWindow->new(); # Create the vertical Scrollbar my $scrollbar = $mw->Scrollbar(); my $lb = $mw->Listbox(-yscrollcommand => ['set' => $scrollbar]); # Configure the Scrollbar to talk to the Listbox widget $scrollbar->configure(-command => ['yview' => $lb]); # Pack the Scrollbar first so that it doesn't disappear when we resize $scrollbar->pack(-side => 'right', -fill => 'y'); $lb->pack(-side => 'left', -fill => 'both'); my %cb; foreach ( qw/a b c d e f g h/ ) { $lb->Checkbutton(-text => "$_", -variable => \$cb{"cb$_"}) -> pack(-side => 'top'); } MainLoop();
BTW, this is made up from fragments scrounged from Mastering Perl/Tk. The comments are from the book as well.

--Jim

Update: After some digging, I'd recommend that you follow the suggestion by Util. I'm not sure what led me to try and embed checkboxes into a listbox widget (one example in the book gives an example packing entry widgets into a text widget, but the whole idea of inserting multiple widgets into either text or listbox widgets seems convoluted and flawed to me).

One alternative is to use a listbox instead of several checkboxes using the "-selectmode => multiple" option, but it appears to work correctly only on NT class boxes (on lesser boxes it ignores the multiselect and uses single select).


In reply to Re: Tk List of Checkboxes? by jlongino
in thread Tk List of Checkboxes? by Flame

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.