File: tk.t

package info (click to toggle)
libtkx-perl 1.09-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 220 kB
  • ctags: 46
  • sloc: perl: 1,270; makefile: 9
file content (57 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!perl -w

use strict;
use Test qw(plan ok);

plan tests => 12;

use Tkx;

my $delay = shift || 1;

my $mw = Tkx::widget->new(".");
$mw->configure(-border => 10);

my $b = $mw->new_button(
    -text => "Test",
    -background => "gray",
    -command => sub {
	if (Tkx::tk_messageBox(
	        -title => "Hi there",
                -icon => "question",
                -message => "Is this a fine day?",
                -parent => ".",
	         -type => "yesno",
            ) eq "yes")
        {
	    $mw->configure(-background => "#AAAAFF");
        }
	else {
	    $mw->configure(-background => "#444444");
	}
    },
);
$b->g_pack;

ok(j($mw->g_winfo_children), $b);
ok(j($mw->_kids), $b);
ok(ref(($mw->_kids)[0]), "Tkx::widget");
ok(j($b->g_winfo_children), "");
ok($b, ".b");
ok($b->m_cget("-text"), "Test");
ok($b->cget("-text"), "Test");
ok($b->configure(-text => "Test me!"), '');
ok(!$b->g_winfo_ismapped);

ok(ref($b->_data), "HASH");
$b->_data->{foo} = "bar";
ok($b->_data->{foo}, "bar");

Tkx::after($delay * 1000, sub {
    ok($b->g_winfo_ismapped);
    $mw->g_destroy;
});

Tkx::MainLoop;

sub j { join(":", @_) }