in reply to PERL/Tk Scrolled Textbox: How do I tell it to automatically scroll down?

use the Scrolled constructer, it can be used to add scrollbars to widgets easier and positioning them using compass orientations is more direct forward as well as they're inherently automatic and appear when needs be. This is better and more concise than the "Scrollbar" method which requires further configuration afterwards to become automatic and so "Scrolled" rules.

Assign the text widget value to a scalar and proceed from there:

#assuming this is a part of a bigger Tk program.. ... my $textWidget=$main->Text( -height=>'20', -width=>'10' )->pack; $textWidget=$main->Scrolled( 'Text', scrollbars=>'w' #this can be n,s,e,w according to compass po +sitions. )->pack; ... MainLoop;
Update: Anyways, I don't know if this sounds easy to do or not but I guess Tk::mega can give you an insight check perldoc for it, also as has been listed in the answers $text->see{INDEX} seems to be what you need check the link provided, it is so informative, other than that run the Tk module command widget from the console, it has many other things that I hope can be helpful.

Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.
  • Comment on Re: PERL/Tk Scrolled Textbox: How do I tell it to automatically scroll down?
  • Download Code

Replies are listed 'Best First'.
Re^2: PERL/Tk Scrolled Textbox: How do I tell it to automatically scroll down?
by Anonymous Monk on Oct 02, 2009 at 11:04 UTC
    Hi, the question was how to have it automatically scroll to the end
    #!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = tkinit(); my $l = $mw->Scrolled(qw' Text -height 2'); $mw->Button( -text => 'add', -command => sub { $l->insert( 'end', localtime() . "\n" ); $l->see('end'); } )->pack; $l->pack; $l->insert( 'end', "hi\nthere\n" ); MainLoop();