| 1 |
# Example of Tk::TableMatrix::SpreadsheetHideRows widget: |
| 2 |
# Table display with hidden detail data |
| 3 |
# |
| 4 |
# This example displays made-up average temperature data |
| 5 |
# for different time periods (quarter and months), and regions. |
| 6 |
|
| 7 |
# Updated to have more spans. 3/8/06. Fully expanding Row 2 and the |
| 8 |
# lower level Rows should look ok, with the spans restoring back |
| 9 |
# to where they were. |
| 10 |
|
| 11 |
use Tk; |
| 12 |
|
| 13 |
use Tk::TableMatrix::SpreadsheetHideRows; |
| 14 |
|
| 15 |
my $top = MainWindow->new; |
| 16 |
|
| 17 |
my $arrayVar = {}; |
| 18 |
|
| 19 |
my @rawdata = (qw/ |
| 20 |
Quarter Month Region State AvgTemp |
| 21 |
1 -- South -- 39 |
| 22 |
2 -- South -- 61 |
| 23 |
3 -- South -- 65 |
| 24 |
4 -- South -- 45 |
| 25 |
/); |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
foreach my $row (0..4){ |
| 30 |
foreach my $col (0..5){ |
| 31 |
next if( $col == 0); |
| 32 |
|
| 33 |
$arrayVar->{"$row,$col"} = shift @rawdata; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
my $expandData = { |
| 39 |
1 => { data => [ [ '','','Jan', 'South','--',33], |
| 40 |
[ '','','Feb', 'South','--',38], |
| 41 |
[ '','','Mar', 'South','--',45], |
| 42 |
], |
| 43 |
tag => 'detail', |
| 44 |
expandData => { |
| 45 |
1 => { data => [ [ '','','', '','Texas',35], |
| 46 |
[ '','','', '','Ok',36], |
| 47 |
[ '','','', '','Ark',37], |
| 48 |
], |
| 49 |
tag => 'detail2', |
| 50 |
}, |
| 51 |
2 => { data => [ [ '','','', '','Texas',41], |
| 52 |
[ '','','', '','Ok',42], |
| 53 |
[ '','','', '','Ark',43], |
| 54 |
], |
| 55 |
tag => 'detail2', |
| 56 |
}, |
| 57 |
3 => { data => [ [ '','','', '','Texas',51], |
| 58 |
[ '','','', '','Ok',52], |
| 59 |
[ '','','', '','Ark',53], |
| 60 |
], |
| 61 |
tag => 'detail2', |
| 62 |
}, |
| 63 |
}, |
| 64 |
}, |
| 65 |
|
| 66 |
2 => { data => [ [ '','','Apr', 'South','--',55], |
| 67 |
[ '','','May', 'South','--',61], |
| 68 |
[ '','','Jun', 'South','--',68], |
| 69 |
], |
| 70 |
tag => 'detail', |
| 71 |
spans => [ 1 => '0,1'], |
| 72 |
expandData => { |
| 73 |
2 => { data => [ [ '','','', '','Texas',58], |
| 74 |
[ '','','', '','Ok',65], |
| 75 |
[ '','','', '','Ark',60], |
| 76 |
], |
| 77 |
tag => 'detail2', |
| 78 |
} |
| 79 |
} |
| 80 |
}, |
| 81 |
4 => { data => [['','Sorry, Detail Data Not Available Until Next month']], |
| 82 |
tag => 'detail', |
| 83 |
spans => [ 1 => '0,3'] |
| 84 |
}, |
| 85 |
|
| 86 |
}; |
| 87 |
|
| 88 |
my $t = $top->Scrolled('SpreadsheetHideRows', -rows => 5, -cols => 6, |
| 89 |
-width => 6, -height => 6, |
| 90 |
-titlerows => 1, -titlecols => 1, |
| 91 |
-variable => $arrayVar, |
| 92 |
-selectmode => 'extended', |
| 93 |
-resizeborders => 'both', |
| 94 |
-selectorCol => 0, |
| 95 |
-expandData => $expandData |
| 96 |
# -state => 'disabled' |
| 97 |
# -colseparator => "\t", |
| 98 |
# -rowseparator => "\n" |
| 99 |
); |
| 100 |
|
| 101 |
# Tags for the detail data: |
| 102 |
$t->tagConfigure('detail', -bg => 'palegreen', -relief => 'sunken'); |
| 103 |
$t->tagConfigure('detail2', -bg => 'lightskyblue1', -relief => 'sunken'); |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
$t->pack(-expand => 1, -fill => 'both'); |
| 108 |
|
| 109 |
Tk::MainLoop; |