The main problem is that you aren't using a variable for -textvariable for the label. The code below fixes that and also passes a reference to the variable through to the sub that updates its contents:
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $time; my $label = $mw->Label(-textvariable => \$time); $label->grid(-row => 1, -column => 1); $mw->repeat(1000, sub {timer (\$time)}); MainLoop; sub timer { my ($varRef) = @_; $$varRef = time(); }
In reply to Re: Tk and textvariable update
by GrandFather
in thread Tk and textvariable update
by rkrasowski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |