Debian Codegraph @

demos/tagMerge2

raw
1 # Script show tag merging behavior with an option set in the
2 # option database.
3 #
4 # Should display with one row hightlighted red and a cell in the row left-justified
5
6 use Tk;
7 use Tk::TableMatrix;
8
9 use strict;
10
11 my $mw = MainWindow->new;
12
13 #$mw->optionAdd('*background', 'blue', 'interactive');
14 $mw->optionAdd('*tablematrix*background', 'skyblue');
15
16 my $table = $mw->TableMatrix(-rows => 5,
17 -cols => 8,
18 -cache => 1,
19 #-bg => 'blue',
20 );
21 $table->pack(-expand => 1, -fill => 'both');
22
23
24 foreach my $row (0..4) {
25 #$table->tagRow('invalid', $row); # swap
26 foreach my $column (0..7) {
27 $table->set("$row,$column", "hello");
28 #$table->tagCell('left', "$row,$column"); # swap
29 }
30 }
31
32 # 'invalid' tag takes priority of 'left' tag, because it is created first,
33 # so the cell 2,3 should be red and center anchored, but see below...
34 $table->tagConfigure("invalid", -background => 'red', -anchor => 'center');
35 $table->tagConfigure("left", -background => 'green', -anchor => 'w');
36
37
38 $table->tagCell('left', '2,3');
39 $table->tagRow('invalid', 2);
40
41 # The tag priority is changed, so the cell 2,3 will be gree and 'w' achored.
42 $table->tagRaise('left', 'invalid');
43
44 # This would have the same effect as the above tagRaise
45 #$table->tagLower('invalid', 'left');
46
47 MainLoop;