dabella12 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks I need a little help :) I'm writing a script that needs to update a label with the current time. here is the code I'm using but it doesn't work
#!/usr/bin/perl use strict; use warnings; use diagnostics; use Tk; use Date::Manip; my $time=&UnixDate('now',"The time is: %r on %B %d, %Y"); my $mw=MainWindow->new(-title=>'Time Test'); my @top = qw/-side top -fill both -padx 2 -pady 2 -expand 1/; my @left = qw/-side left -fill both -padx 2 -pady 2 -expand 1/; my $frm=$mw->Frame(-bd =>2); my $frm1=$mw->Frame(-bd =>2); my $oper=$frm->Button( -text => "Entrada De Operaciones", -command => sub{print "Hello World\n"}, ); my $client =$frm->Button( -text => 'Informe De Clientes', -command => sub{print "Hello World\n"}, ); my $general =$frm->Button( -text => 'Informe General', -command => sub{print "Hello World\n"}, ); my $util =$frm->Button( -text => 'Utilidades', -command => sub{print "Hello World\n"}, ); my $exit =$frm->Button( -text => 'Exit Application', -command => sub{exit}, ); my $lb=$mw->Label(-text=>\&update_time)->pack(@top); $frm->pack(@top); $oper->pack(@top); $client->pack(@top); $general->pack(@top); $util->pack(@top); $exit->pack(@top); MainLoop; sub update_time { $time=&UnixDate('now',"The time is: %r on %B %d, %Y"); print "$time\n"; $lb->configure(-text=>"$time"); $mw->update; $mw->after(1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk Update
by CountOrlok (Friar) on Apr 22, 2013 at 15:44 UTC | |
by dabella12 (Acolyte) on Apr 29, 2013 at 15:22 UTC | |
by stefbv (Priest) on Apr 29, 2013 at 16:22 UTC | |
by dabella12 (Acolyte) on May 03, 2013 at 14:23 UTC |