in reply to Tk Scrolled Text and Large Files
Before even trying to display the data, I would split it, and load it into a hash. Then work out a scheme, for the text widget just to display a designated number of hash elements, like huge pad. Then when you want to save the whole file, just loop thru all the hash keys and save(concantate) the values.
And don't overlook the power that tags can add to your program, here is a simple example.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; my $t = $mw->Scrolled('Text', -scrollbars => 'osoe' )->pack; for(1..100){ $t->tagConfigure( 'data'.$_, -data => $_ x 20, ); } for(1..100){ $t->insert('end', 'Line'."$_\n", ['datarider','data'.$_ ]); } $t->tagBind( 'datarider', '<Enter>', sub { getdata($t) } ); $t->tagBind( 'datarider', '<Leave>', sub { getdata($t) } ); $t->bind( '<Motion>', sub{ getdata($t) } ); MainLoop; sub getdata { my ( $text_widget ) = @_; my $x = $text_widget->pointerx - $text_widget->rootx; my $y = $text_widget->pointery - $text_widget->rooty; #print "$x $y\n"; my $txt_index = $text_widget->index( '@' . $x . ',' . $y ); #warn $txt_index; my ( $line, $char ) = ( $txt_index =~ /^(.+?)\.(.+?)$/ ); my @tags = $text_widget->tagNames($txt_index); print "@tags\n"; foreach my $tag(@tags){ print $text_widget->tagCget($tag,'data'),"\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk Scrolled Text and Large Files
by Anonymous Monk on Oct 17, 2005 at 13:16 UTC |