Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!perl
$| = 1;
for (0..3) {
sleep(1);
print "$_\n";
}
#!perl
use Tk;
my $mw = MainWindow->new;
# give it a title
$mw->configure(-title=>'Uber Simple Tk App.');
# set it's size and location on the screen
$mw->geometry('300x40+100+100');
# build a button to call the counter app.
my $button = $mw->Button(-text=>'Run Counter',
-command=>\&call_counter )
->pack(-side=>'left');
# build an 'Exit' button.
$mw->Button(-text=>'Exit',
-command=>sub{exit})
->pack(-side=>'right');
# build a label to show the responses from the counter app.
my $window_text;
my $label = $mw->Label(-textvariable=>\$window_text)
->pack(-side=>'left');
MainLoop;
#-------------------------------------------
sub call_counter {
# disable the counter button.
$button->configure(-state=>'disabled');
# reset label text to nada
$window_text = '';
# call counter.pl and display results as they are returned
# through the pipe.
open(CMD,"counter.pl |") or die "Failed to open trivial.pl, $!\n";
while (<CMD>) {
$window_text .= $_ ;
chomp($window_text);
# force an update of the label widget to display new text.
$label->update;
}
close CMD;
$window_text .= "\nDone.";
$label->update;
# enable button.
$button->configure(-state=>'normal');
}