in reply to insert in Text widget

shmem's code is great++. I took a different tack, cleaned your code up a little, and came up with this:

#!/usr/bin/perl use strict; use warnings; use Tk; use IO::File; my $mw = MainWindow->new(); my $st = $mw->Scrolled( 'Text', -scrollbars => 'eo' )->pack(); $st->repeat( 3000, \&list ); MainLoop; sub list { my $fh = IO::File->new(); open $fh, q{<}, '/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread- +multi/Tk/Text.pm'; while (<$fh>) { $st->insert( 'end', "line $_\n" ); return; } } 1;

Update: Fixed. It should work now. Sorry for the delay. The main reason that I did it this way is that I used Perl::Critic, and it recommended IO::File. Also, it recommended a 3-arg open, which seems to work a little better. There's an online Perl::Critic at http://perlcritic.com/

Replies are listed 'Best First'.
Re^2: insert in Text widget
by xiaoyafeng (Deacon) on May 28, 2007 at 01:26 UTC
    I've try your code, but it seems not work. Could you comment your key changes?


    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction