File: browseentry2.t

package info (click to toggle)
perl-tk 1%3A804.036%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 35,284 kB
  • sloc: ansic: 349,560; perl: 52,292; sh: 12,678; makefile: 5,700; asm: 3,565; ada: 1,681; pascal: 1,082; cpp: 1,006; yacc: 883; cs: 879
file content (95 lines) | stat: -rw-r--r-- 2,304 bytes parent folder | download | duplicates (10)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl -w
# -*- perl -*-

#
# $Id: browseentry2.t,v 1.9 2003/04/21 19:49:35 eserte Exp $
# Author: Slaven Rezic
#

use strict;

use Tk;
use Tk::BrowseEntry;

BEGIN {
    if (!eval q{
	use Test;
	1;
    }) {
	print "# tests only work with installed Test module\n";
	print "1..1\n";
	print "ok 1\n";
	exit;
    }
}

BEGIN { plan tests => 6 }

if (!defined $ENV{BATCH}) { $ENV{BATCH} = 1 }

my $top = new MainWindow;
$top->geometry("+10+10");
my $var;
my $robe = $top->BrowseEntry
    (
     -label      => "readonly, classic style",
     -state      => 'readonly',
     -autolistwidth   => 1,     # list width is dynamically calculated
     -autolimitheight => 1,     # limit height of browseentry to number
                                # of items
     -browsecmd  => sub { warn "-browsecmd:  @_\n" }, # old plain callback
     -browse2cmd => sub { warn "-browse2cmd: @_\n" }, # -browsecmd with index as argument
     -variable   => \$var,
    )->pack;

$robe->insert("end", @INC);

ok(ref $robe, 'Tk::BrowseEntry');
ok($robe->isa('Tk::BrowseEntry'), 1);

my $var2;
my $robe2 = $top->BrowseEntry
    (
     -label      => "normal, windows style",
     -autolistwidth   => 1,     # list width is dynamically calculated
     -autolimitheight => 1,     # limit height of browseentry to number
                                # of items
     -style => 'MSWin32',
     -variable   => \$var2,
    )->pack;
$robe2->insert("end", 1, 2, 3, "a very long entry exceeding the normal width");

ok(ref $robe2, 'Tk::BrowseEntry');
ok($robe2->isa('Tk::BrowseEntry'), 1);

{
    my $var;
    my $robe = $top->BrowseEntry
	(
	 -label      => "readonly, windows style",
	 -autolistwidth   => 1,     # list width is dynamically calculated
	 -autolimitheight => 1,     # limit height of browseentry to number
	                            # of items
	 -style => 'MSWin32',
	 -state => 'readonly',
	 -variable   => \$var,
	)->pack;
    $robe->insert("end", 1, 2, 3, "a very long entry exceeding the normal width");

    ok(ref $robe, 'Tk::BrowseEntry');
    ok($robe->isa('Tk::BrowseEntry'), 1);

    $robe->configure(-variable => \$var);
}

$top->Button(-text => "Ok",
	     -command => sub {
		$top->destroy;
	    })->pack;
$top->after(60*1000, sub { $top->destroy });

if (!$ENV{BATCH}) {
    MainLoop;
}

__END__