MadMax has asked for the wisdom of the Perl Monks concerning the following question:
Please help me to figure out what I am doing wrong in inserting the text into the text widget. What I get is the total output at once and what I want is a line-by-line insert into the widget window. Here is an example of what I am doing.
----------------------------
#!/usr/local/bin/perl use Tk; my $submain = MainWindow->new(); $status = $submain->Button(-text => 'Click to Clear', -command => sub {$submain->destroy;} ); $status->pack; $text1 = $submain->Text ('-width'=>100, 'height'=>20); $text1->pack(-side => 'left', -fill => 'y'); $text1->insert('end', "start\n"); $text1->pack; for(my $loop=0; $loop <= 3; $loop++ ) { sleep 1; print "$loop\n"; if ( $loop == 1 ) { $line = "$loop case 1\n"; } elsif ( $loop == 2 ) { $line = "$loop case 2\n"; } else { $line = "$loop something else\n"; } $text1->insert('end', "$line"); $text1->pack; } MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Refresh text widget
by Anonymous Monk on Mar 20, 2002 at 09:39 UTC | |
by Anonymous Monk on Mar 20, 2002 at 11:18 UTC | |
|
Re: Refresh text widget
by ChOas (Curate) on Mar 20, 2002 at 07:53 UTC | |
by Anonymous Monk on Mar 20, 2002 at 09:27 UTC |