Skip to content

Instantly share code, notes, and snippets.

@mattn
Created October 5, 2012 09:37
Show Gist options
  • Select an option

  • Save mattn/3838956 to your computer and use it in GitHub Desktop.

Select an option

Save mattn/3838956 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Encode;
use Encode::Locale;
use UV;
use Glib;
use Gtk2 -init;
use Time::Piece;
my $w = Gtk2::Window->new('toplevel');
$w->set_title("timer");
my $v = Gtk2::VBox->new(0, 1);
my $l = Gtk2::Label->new();
$v->add($l);
$w->add($v);
$w->set_default_size(300, 20);
$w->show_all;
my $t = UV::timer_init();
UV::timer_start($t, 1000, 1000, sub {
$l->set_label(decode(locale => localtime->strftime));
});
my $i = UV::idle_init();
UV::idle_start($i, sub {
Gtk2->main_iteration_do(0);
});
$w->signal_connect(destroy => sub {
UV::close($t);
UV::close($i);
});
UV::run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment