in reply to Re^2: How can I get indefinite scroll to work in a TK text widget
in thread How can I get indefinite scroll to work in a TK text widget
Ah. Makes more sense. While perl is busy executing display_text(), the GUI doesn't get updated. You need Tk::after or ::repeat for that:
use Tk; $bottomFrame = MainWindow->new(); my $txt_summary = $bottomFrame->Scrolled( "Text", -background => 'blue', -foreground => 'white', -height => '1', -takefocus => '0', -width => '40', -scrollbars => 'oe', )->pack(qw(-fill both -ex +pand 1)); open(FH, "cuentos.txt") || die "no Abrio nada"; sub display_text { if(eof(FH)) { $bottomFrame->afterCancel($bottomFrame->{RepeatID}); close (FH); $txt_summary -> Insert("\n== FIN ==",'end'); return; } else { chomp(my $line = <FH>); $txt_summary -> Insert("\n$line",'end'); } $txt_summary->see('end'); } $bottomFrame->{RepeatID} = $bottomFrame->repeat(500, \&display_text); MainLoop; __END__
But probably you want Tk::fileevent. Note also that "Scrolled" means "attach a scrollbar to it", and not "scroll this widget".
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How can I get indefinite scroll to work in a TK text widget
by padawan_linuxero (Scribe) on May 16, 2008 at 18:05 UTC | |
by TGI (Parson) on May 17, 2008 at 01:06 UTC |