Debian Codegraph @

demos/maxsize

raw
1 ## maxsize.tcl
2 ##
3 ## This demo uses a really big table. The big startup time is in
4 ## filling the table's Tcl array var.
5 ##
6 ## [email protected]
7 ## Converted to perl/tk by John Cerney 7/24/00
8
9
10 use Tk;
11
12 use Tk::TableMatrix;
13
14 my $top = MainWindow->new;
15
16 my $arrayVar = {};
17
18 print "Filling Array...\n";
19 my ($rows,$cols) = (40000, 10);
20 foreach my $row (0..($rows-1)){
21 foreach my $col (0..($cols-1)){
22 $arrayVar->{"$row,$col"} = "$row,$col";
23 }
24 }
25
26 print "Creating Table...\n";
27 ## Test out the use of a callback to define tags on rows and columns
28 sub colSub{
29 my $col = shift;
30 return "OddCol" if( $col > 0 && $col%2) ;
31 }
32
33 my $label = $top->Label(-text => "TableMatrix v2 Example");
34
35 my $t = $top->Scrolled('TableMatrix', -rows => $rows, -cols => $cols,
36 -width => 6, -height => 6,
37 -titlerows => 1, -titlecols => 1,
38 -variable => $arrayVar,
39 -coltagcommand => \&colSub,
40 -colstretchmode => 'last',
41 -rowstretchmode => 'last',
42 -selectmode => 'extended',
43 -selecttitles => 0,
44 -drawmode => 'slow',
45 );
46
47 my $button = $top->Button( -text => "Exit", -command => sub{ $top->destroy});
48
49 # hideous Color definitions here:
50 $t->tagConfigure('OddCol', -bg => 'brown', -fg => 'pink');
51 $t->tagConfigure('title', -bg => 'red', -fg => 'blue', -relief => 'sunken');
52 $t->tagConfigure('dis', -state => 'disabled');
53
54 my $i = -1;
55 my $first = $t->cget(-colorigin);
56 my $anchor;
57 foreach $anchor( qw/ n s e w nw ne sw se c /){
58 $t->tagConfigure($anchor, -anchor => $anchor);
59 $t->tagRow($anchor, ++$i);
60 $t->set( "$i,$first",$anchor);
61 }
62 $top->fontCreate('courier', -family => 'courier', -size => 10);
63 $t->tagConfigure('s', -font => 'courier', -justify => 'center');
64
65
66 $t->colWidth( -2 => 8, -1 => 9, 0=> 12, 4=> 14);
67
68 $label->pack( -expand => 1, -fill => 'both');
69
70 $t->pack(-expand => 1, -fill => 'both');
71 $button->pack(-expand => 1, -fill => 'both');
72
73
74
75
76 Tk::MainLoop;