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.
#!/usr/local/bin/perl -w
use Tk;
$top = MainWindow->new();
$frame = $top->Frame( -height => '6c', -width => '6c',
-background => 'black', -cursor => 'gobbler' );
$frame->pack;
$top->bind( '<Any-KeyPress>' => sub
{
my($c) = @_;
my $e = $c->XEvent;
my( $x, $y, $W, $K, $A ) = ( $e->x, $e->y, $e->K, $e->W, $e->A );
print "A key was pressed:\n";
print " x = $x\n";
print " y = $y\n";
print " W = $K\n";
print " K = $W\n";
print " A = $A\n";
} );
MainLoop();
MainLoop();
sub rutin
{
while(1){}
}
use Tk;
my $mw = MainWindow->new (
-title => 'Demo',
);
$mw->Label (
-text => "Press the button below and your GUI will freeze\n"
. "up for 30 seconds and appear broken.",
)->pack;
$mw->Button (
-text => "Click Here",
-command => \&do_long_operation,
)->pack;
MainLoop;
sub do_long_operation {
for (my $i = 0; $i < 30; $i++) {
sleep(1);
}
return;
}
sub do_long_operation {
for (my $i = 0; $i < 30; $i++) {
sleep(1);
$mw->update; # update the GUI
}
return;
}
sub rutin {
while (1) {
select (undef,undef,undef,0.01); # sleep 1/10th of a second
# so that the GUI never appears stuck even for
# a second, but so Perl will be slowed down and
# not devour 100% CPU.
$top->update; # Update Tk.
# Any keypress bindings you defined will be
# processed every time update() is called.
}
}
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'