| 1 |
#!/usr/bin/perl -w |
| 2 |
# -*- perl -*- |
| 3 |
|
| 4 |
# |
| 5 |
# $Id: $ |
| 6 |
# Author: Slaven Rezic |
| 7 |
# |
| 8 |
|
| 9 |
use strict; |
| 10 |
|
| 11 |
use Tk; |
| 12 |
|
| 13 |
BEGIN { |
| 14 |
if (!eval q{ |
| 15 |
use Test::More; |
| 16 |
1; |
| 17 |
}) { |
| 18 |
print "1..0 # skip: no Test::More module\n"; |
| 19 |
exit; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
BEGIN { plan tests => 7 } |
| 24 |
|
| 25 |
my $mw = MainWindow->new; |
| 26 |
|
| 27 |
$mw->withdraw; |
| 28 |
$mw->geometry("+10+10"); |
| 29 |
$mw->Message(-text => "Set the icon with iconimage and iconphoto")->pack; |
| 30 |
my $icon = $mw->Photo(-format => 'gif', |
| 31 |
-file => Tk->findINC('Xcamel.gif')); |
| 32 |
$mw->iconimage($icon); |
| 33 |
$mw->deiconify; |
| 34 |
$mw->idletasks; |
| 35 |
pass("Set iconimage"); |
| 36 |
|
| 37 |
tk_sleep(0.5); |
| 38 |
|
| 39 |
SKIP: { |
| 40 |
skip("iconphoto is not implemented for Windows", 1) |
| 41 |
if $Tk::platform eq 'MSWin32'; |
| 42 |
|
| 43 |
my $icon2 = $mw->Photo(-file => Tk->findINC("icon.gif")); |
| 44 |
$mw->withdraw; |
| 45 |
$mw->iconphoto('-default', $icon2); |
| 46 |
$mw->deiconify; |
| 47 |
|
| 48 |
my $t = $mw->Toplevel; |
| 49 |
$t->geometry("+100+20"); |
| 50 |
$t->Message(-text => "This toplevel should also get the same icon")->pack; |
| 51 |
|
| 52 |
$mw->idletasks; |
| 53 |
pass("Set iconphoto"); |
| 54 |
} |
| 55 |
|
| 56 |
{ |
| 57 |
my($wrapper_id, $menu_height) = $mw->wrapper; |
| 58 |
ok(defined $wrapper_id, "Wrapper Id <$wrapper_id>"); |
| 59 |
ok(defined $menu_height, "Menu height <$menu_height>"); |
| 60 |
} |
| 61 |
|
| 62 |
if (0) { # capture/release not anymore available in Tk??? |
| 63 |
SKIP: { |
| 64 |
skip("wmCapture/Release not implemented for Windows", 1) |
| 65 |
if $Tk::platform eq 'MSWin32'; |
| 66 |
|
| 67 |
my $t2 = $mw->Toplevel; |
| 68 |
$t2->capture; |
| 69 |
$mw->update; |
| 70 |
$mw->after(100); |
| 71 |
$t2->release; |
| 72 |
pass("wm capture/release ok"); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
{ |
| 77 |
is($mw->wmTracing, "", "wmTracing"); |
| 78 |
$mw->wmTracing(1); |
| 79 |
is($mw->wmTracing, 1); |
| 80 |
$mw->wmTracing(0); |
| 81 |
is($mw->wmTracing, ""); |
| 82 |
} |
| 83 |
|
| 84 |
$mw->after(1000,[destroy => $mw]); |
| 85 |
MainLoop; |
| 86 |
|
| 87 |
sub tk_sleep { |
| 88 |
my($s) = @_; |
| 89 |
my $sleep_dummy = 0; |
| 90 |
$mw->after($s*1000, |
| 91 |
sub { $sleep_dummy++ }); |
| 92 |
$mw->waitVariable(\$sleep_dummy) |
| 93 |
unless $sleep_dummy; |
| 94 |
} |
| 95 |
|
| 96 |
__END__ |