I've knocked up this little app. which inserts ten items into the listbox every time you hit the <Insert> button. It seems to update the scroll bar ok on my system, Sun Ultra 30, Solaris 9, perl 5.8.4, Tk-804.027.

use strict; use warnings; use Tk; my $rcGetTen = do { my $count = 0; sub { my @arr; push @arr, q{Item } . ++ $count for 1 .. 10; return @arr; }; }; my $bgColour = q{LightSteelBlue3}; my %labelColours = ( -foreground => q{NavyBlue}, -background => q{LemonChiffon} ); my %buttonColours = ( -background => q{grey35}, -foreground => q{yellow2}, -activebackground => q{grey45}, -activeforeground => q{yellow}, -disabledforeground => q{grey55} ); my %commonListboxOpts = ( -setgrid => 1, -scrollbars => q{e}, -selectmode => q{single}, -selectforeground => q{grey35}, -selectbackground => q{AntiqueWhite}, -exportselection => 0 ); my $mainWin = MainWindow->new( -background => $bgColour, ); $mainWin->title(q{scrollListbox}); my $listboxFrame = $mainWin->Frame( -relief => q{flat}, -background => $bgColour, -borderwidth => 2, ); $listboxFrame->pack( -side => q{top}, ); my $listbox = $listboxFrame->Scrolled( q{Listbox}, %commonListboxOpts, -width => 15, -height => 6, -setgrid => 1, ); $listbox->pack( -padx => 5, -pady => 5, -fill => q{y}, -expand => 1, -anchor => q{n}, ); my $controlButtonFrame = $mainWin->Frame( -relief => q{flat}, -background => $bgColour, -borderwidth => 2, ); $controlButtonFrame->pack( -side => q{top}, ); my $quitButton = $controlButtonFrame->Button( %buttonColours, -width => 6, -text => q{Quit}, -command => sub {exit;}, ); $quitButton->pack( -side => q{right}, -padx => 5, -pady => 5, ); my $insertButton = $controlButtonFrame->Button( %buttonColours, -width => 6, -text => q{Insert}, -command => sub { $listbox->insert( q{end}, $rcGetTen->() ) }, ); $insertButton->pack( -side => q{right}, -padx => 5, -pady => 5, ); MainLoop();

I hope this is of interest.

Cheers,

JohnGG


In reply to Re^3: TK ListBox and Scrollbar by johngg
in thread TK ListBox and Scrollbar by SteveS832001

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.