Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
------ It print $n in <STDOUT> the way I would have it update the widget (except that the widget would erase the previous element). This is a really simplified example of a piece of code that I am working on, and therefore I would prefer to keep the foreach loop, but if anyone has suggestions, I would really appreciate it.use Tk; $mw = new MainWindow; $rec1 = $mw->Canvas(-height => "90", -width => "450")->pack(); @junk = (0,1,2,3,4,5,6,7,8,9); foreach $n (@junk) { delay_type($n); } MainLoop; sub delay_type { $mw->after(500); $rec1->createRectangle(1,1,450,90, -fill => "black"); $rec1->createText(225,45, -text => "$n", -justify => "center", -fill => "yellow", -font => "times 62"); print $n; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Updating a Tk Widget from a foreach loop
by danger (Priest) on Mar 21, 2001 at 11:31 UTC |