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
| #!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::TableMatrix;
my $fenetre_principale = MainWindow->new;
my $arrayVar = {};
for my $row ( 0 .. 7 ) {
for my $col ( 0 .. 7 ) {
# Arrondit des nombres
#$arrayVar->{"$row,$col"} = sprintf '%.2f', $col+1.5487542158765235*$row;
$arrayVar->{"$row,$col"} = $col + 1.5487542158765235 * $row;
}
}
my $tableau = $fenetre_principale->Scrolled(
'TableMatrix',
-variable => $arrayVar,
-selectmode => 'extended',
);
$tableau->tagConfigure(
'non-modifiable',
-bg => 'red',
-state => 'disabled',
);
# La cellule 3,3 est désactivée, non éditable
$tableau->tagCell( 'non-modifiable', "3,3" );
# Les cellules actives auront une couleur green
$tableau->tagConfigure( 'active', -background => 'green' );
# Les cellules sélectionnées auront une couleur brown
$tableau->tagConfigure( 'sel', -background => 'brown' );
# J'affiche la valeur de la cellule 4,2
print 'Cellule 4,2 : ', $tableau->get('4,2'), "\n";
# Je mets le colonne 2 à une largeur de 50 pixels
$tableau->colWidth( 1, 50 );
$tableau->pack( -expand => 1, -fill => 'both' );
MainLoop; |
Partager