Created
October 5, 2012 09:37
-
-
Save mattn/3838956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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