I have some "Text" widgets that are created with Tk. I've figured out how to add scrollbars, but it the data printed to the text area goes off the bottom of the text area, the user must grab the scrollbar (or click the down arrow or the trough) to see the new data. What I would like to do is have the Text widget automatically scroll down as new data is added. Here's how I create the Text widget with a scrollbar.

$txtSummary = $root->Scrolled( 'Text', -background => 'blue', -foreground => 'white', -height => '1', -takefocus => '0', -width => '40', -scrollbars => 'oe' )->pack;

That works fine, but this is what I thought was necessary to get the Text widget to "auto" scroll:

$txtSummary->Subwidget( 'yscrollbar' )->configure( -command => [ 'yview' => $txtSummary ] );

That has no apparent affect. Further, the user must move their mouse over the scrollbar to even have the scrollbar's length be correct. In other words, as soon as enough text shows up to mandate a scrollbar, the scrollbar appears, but the bar is the full height of the text area. Only when you do a mouseover does the scrollbar shrink to its correct size.

Hope this made sense :)

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Auto-scrolling scrollbars with Perl Tk by Ovid

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.