| 1 |
#!/usr/local/bin/perl -w |
| 2 |
use strict; |
| 3 |
use Tk; |
| 4 |
|
| 5 |
my $mw = MainWindow->new; |
| 6 |
|
| 7 |
my $bits = pack("b8"x5, |
| 8 |
"........", |
| 9 |
"...11...", |
| 10 |
"..1111..", |
| 11 |
".111111.", |
| 12 |
"........"); |
| 13 |
|
| 14 |
$mw->DefineBitmap('increment' => 8,5, $bits); |
| 15 |
# And of course, decrement is the reverse of increment :-) |
| 16 |
$mw->DefineBitmap('decrement' => 8,5, scalar reverse $bits); |
| 17 |
|
| 18 |
my $value = 1000; |
| 19 |
|
| 20 |
my $up = $mw->Button(-bitmap => 'increment', -pady => 0, -command => sub { $value++ } ); |
| 21 |
my $dn = $mw->Button(-bitmap => 'decrement', -pady => 0, -command => sub { $value-- } ); |
| 22 |
my $en = $mw->Entry(-textvariable => \$value, -justify => 'right', -width => 6); |
| 23 |
my $qu = $mw->Button(-text => 'Quit', -command => [destroy => $mw]); |
| 24 |
|
| 25 |
Tk::grid($en,$up); |
| 26 |
Tk::grid('^',$dn); |
| 27 |
Tk::grid($qu,'-'); |
| 28 |
|
| 29 |
MainLoop; |
| 30 |
|
| 31 |
|