| 1 |
#!/usr/bin/perl -w |
| 2 |
# -*- perl -*- |
| 3 |
|
| 4 |
use strict; |
| 5 |
|
| 6 |
use Tk; |
| 7 |
|
| 8 |
BEGIN { |
| 9 |
if (!eval q{ |
| 10 |
use Test::More; |
| 11 |
1; |
| 12 |
}) { |
| 13 |
print "1..0 # skip: no Test::More module\n"; |
| 14 |
exit; |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
BEGIN { plan tests => 5 } |
| 19 |
|
| 20 |
my $mw = MainWindow->new; |
| 21 |
$mw->geometry("+10+10"); |
| 22 |
|
| 23 |
{ |
| 24 |
my $cb = $mw->Checkbutton->pack; |
| 25 |
is(ref $cb, "Tk::Checkbutton", "It's a checkbutton"); |
| 26 |
is($cb->{Value}, undef, "No value at beginning"); |
| 27 |
$cb->select; |
| 28 |
is($cb->{Value}, 1, "... but now"); |
| 29 |
} |
| 30 |
|
| 31 |
{ |
| 32 |
# new Button options |
| 33 |
my $f = $mw->Frame->pack(-fill => 'x'); |
| 34 |
my $incr = 0; |
| 35 |
$f->Button(-text => "Repeat & ridge", |
| 36 |
-image => $mw->Photo(-file => Tk->findINC("Xcamel.gif")), |
| 37 |
-compound => 'left', |
| 38 |
-overrelief => 'ridge', |
| 39 |
-repeatdelay => 200, |
| 40 |
-repeatinterval => 100, |
| 41 |
-command => sub { $incr++ }, |
| 42 |
)->pack(-side => 'left'); |
| 43 |
$f->Label(-text => "increments:")->pack(-side => 'left'); |
| 44 |
$f->Label(-textvariable => \$incr)->pack(-side => 'left'); |
| 45 |
pass("Button with new options"); |
| 46 |
} |
| 47 |
|
| 48 |
{ |
| 49 |
# Label and -state |
| 50 |
my $f = $mw->Frame->pack(-fill => 'x'); |
| 51 |
$f->Label(-state => "normal", -text => "normal: red on white", |
| 52 |
-background => 'white', -foreground => 'red')->pack(-fill => 'x'); |
| 53 |
$f->Label(-state => "active", -text => "active: green on white", |
| 54 |
-activebackground => 'white', -activeforeground => 'green')->pack(-fill => 'x'); |
| 55 |
$f->Label(-state => "disabled", -text => "disabled: blue on white", |
| 56 |
-background => 'white', -disabledforeground => 'blue')->pack(-fill => 'x'); |
| 57 |
pass("Label with states"); |
| 58 |
} |
| 59 |
|
| 60 |
if ($ENV{PERL_INTERACTIVE_TEST}) { |
| 61 |
MainLoop; |
| 62 |
} |
| 63 |
|
| 64 |
__END__ |