use Tk; use strict; my $mw = MainWindow->new(title => "Timer"); my $elapsed_sec = 0; my $elapsed_sec_label = $mw->Label(-textvariable => \$elapsed_sec)->pack(); $mw->Button(text => "reset", command => sub {$elapsed_sec = 0})->pack(); $mw->repeat(1000 => sub {$elapsed_sec ++}); #this is repeated every second, and you can put your is_playing here MainLoop;