in reply to Refresh Display in Perl Tk
If you use the '-textvariable' option (instead of '-text'), you can update the variable and the widget will also update. Also, instead of calling Tk::After, use the 'repeat' method on the Label widget itself. Here is one way (I've replaced your gettime() function with a simple call to localtime() in scalar context to make the date string):
#!/usr/bin/perl -w use strict; use Tk; my $top = new MainWindow; my $text = localtime(); my $id = $top->Label(-textvariable => \$text)->pack; $id->repeat(1000,sub{$text = localtime()}); MainLoop; __END__
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Refresh Display in Perl Tk
by thunders (Priest) on Nov 04, 2001 at 01:27 UTC |