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__
In reply to Re: Refresh Display in Perl Tk
by danger
in thread Refresh Display in Perl Tk
by thunders
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |