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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
#!/usr/bin/perl
use warnings;
#use Switch;
use strict;
#use explicit;
use Tk::png;
use Tk; # Appel du module Tk
use Tk::TableMatrix;
use Tk::Widget;
use Tk::JComboBox;
my $fenetre;
my $AfficheData;
my $table;
my @TabLibelle = ("Seq.","Date Heure","Adresse IP","Code Erreur","Sévérité","Mnemonic","Description");
my @TabLargeur = (5, 15, 15, 11, 8 ,8,11);
my $var_rb;
my @TabDataLigne;
my $lg;
my $Poste;
my $CptLignes;
# my @choices;
# my @TabLignes;
# my $NbTabLignes;
my $row ;
my $number_rows ;
# ==============================================================================!
# Sous Programme | AfficheTableauData | Local !
# ==============================================================================!
# !
# Description : Affiche les données dans le tableau !
# !
# Pararmetre : un tableau des données => soit issu d'un fichier log ou soit issu d'un tableau !
# !
# !
# Remarque(s) : !
# --------------------------------------------------------------------------------------------------------------------------------------------!
sub AfficheTableauData ($$@){
my ($type,$NbTabLignes,@TabDataLignes) = @_;
$CptLignes = 0;
$row =1;
$number_rows = 0;
#$table->update;
#-----------------------------------------------------------#
# Boucle sur l'ensemble des lignes du tableau #
#-----------------------------------------------------------#
while ($CptLignes <= $NbTabLignes){
$CptLignes ++;
print "nombre de ligne $number_rows\n";
print "cpt de ligne $row\n";
#---------------------------------------------#
# Insertion d'une ligne si nécessaire #
#---------------------------------------------#
if ( $number_rows <= $row ) {
$table->insertRows( 'end',1 ) ;
}
#---------------------------------------------------------#
# Calcul du nombre de lignes dans le tableau #
#----------------------------------------------------------#
$number_rows = $table->cget( -rows );
#-----------------------------------------------------------#
# renseigne les lignes affichées avec les datas #
#-----------------------------------------------------------#
$AfficheData->{"$row,1"} = $TabDataLignes[$row-1];
$row++;
}
}
# ==============================================================================!
# Sous Programme | cb_rbutton | Local !
# ==============================================================================!
# !
# Description : affiche en fonction du radio bouton les données specifiques !
# !
#---------------------------------------------------------------------------------------------------------------------------------------------!
sub cb_rbutton {
# Affichage du tableau
my @TabTmp = ("cinq","six","sept");
my $nbligne = $#TabTmp + 1;
AfficheTableauData(2,$nbligne,@TabTmp);
$table->set row 2,3 {2,3 2,4 2,5} ;
$fenetre->update;
return;
}
# ==============================================================================#
# Programme Principal #
# ==============================================================================#
# #
# Description : creation de la fenetre #
# #
#---------------------------------------------------------------------------------------------------------------------------------------------#
$fenetre = new MainWindow(
-title => 'Traitement des logs',
-background => 'LightBlue1',
);
# Taille minimale de ma fenêtre
$fenetre->minsize( 1387, 812 );
# Affichage du GroupBox contenant les radio bouttons
my $GroupBox = $fenetre->LabFrame(-label => 'Choix du type',
-background => 'LightBlue1',
)->place(qw/-x 150 -y 10 -width 600 -height 50/);
# Affichage des radio bouttons
my $increment = 0;
my $PositionX = 10;
foreach my $p ("Code Erreur", "Adr IP","Mnemonic", "Severité", "Tous" ) {
$GroupBox->Radiobutton(
-text => "$p",
-relief => 'flat',
-value => $p,
-background => 'LightBlue1',
-variable => \$var_rb,
-command => [\&cb_rbutton, $GroupBox],
)->place(-x => $PositionX, -y => 1, -width => 100, -height => 30);
$PositionX = $PositionX + 120;
}
# Affichage du tableau
$AfficheData = {};
$table = $fenetre->Scrolled(
'TableMatrix',
-rows => 0,
-justify => 'left',
-cols => 2,
-rowheight => 2, # Hauteur de la ligne
-variable => $AfficheData,
-rowtagcommand => \&type_row,
-background => "#454545",
-titlerows => 1,
-titlecols => 1,
-drawmode => 'single',
-selectmode => 'extended',
-scrollbars => 'osoe',
)->place(qw/-x 10 -y 150 -width 1360 -height 650 /);
my @TabLignes = ("un","deux","trois","quatre");
my $NbTabLignes = $#TabLignes +1;
#($NbTabLignes,@TabLignes) = LectureFicLog();
#------------------------------------!
# Appel affichage du tableau !
#------------------------------------!
AfficheTableauData(1,$NbTabLignes,@TabLignes);
# Configuration des lignes paires et impaires
$table->tagConfigure(
'pair_row',
-bg => 'white',
-fg => 'black',
-relief => 'sunken',
-anchor => 'w',
-state => 'disabled');
$table->tagConfigure(
'impair_row',
-bg => '#00C0E0',
-fg => 'black',
-relief => 'sunken',
-anchor => 'w',
-state => 'disabled');
$table->tagConfigure( 'title', -bg => '#F0E0FF', -fg => 'black', -relief => 'sunken' );
MainLoop;
# Permet d'assigner un tag aux lignes paires et impaires
sub type_row {
my $row = shift;
my $tag_row = ( $row > 0 && $row % 2 == 0 ) ? "pair_row" : "impair_row";
return $tag_row;
} |