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
| #!/usr/bin/perl
# be strict
use strict;
use warnings;
use Tk;
use Tk::Adjuster;
use Tk::Pane;
use Tk::Text;
use utf8;
use Encode;
##########################################################
# #
# G U I #
# #
##########################################################
my $mw = new MainWindow;#ou MainWindow->new();
$mw->title ("My frame");
$mw->geometry("1250x600");
my $cell;
my @textSender;
my @textReceiver;
my @all_lines = (
'2', '1266619337', 'test',
'3', '1266624381', 'tsdfhsldjfhnsldkflksdjflks,dfssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssk:ds,fsdfsdfsdfsdfsdfsdfest',
'2', '1266625519', 'test',
'3','1266662837', "test",
'3','1266664673', "test",
'3','1266777388', "test",
'3',1266778423, "test",
'2',1266787476, "tesdfffffffffffffffffffffffqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqfffffffffffffffffffffffffffft",
'2',1266787924, "test",
'3',1266788626, "test",
'2',1266790411, "test",
'3',1266796849, "test",
'2',1266797836, "test",
'3',1266957673, "test",
'2',1266959468, "test",
'3',1266962012, "test",
'2',1266966835, "test",
'3',1266968068, "test",
'3',1266969797, "test",
'3',1267005658, "test",
'2',1267006399, "test",
'2',1266797836, "test",
'3',1266957673, "test",
'2',1266959468, "test",
'3',1266962012, "test",
'2',1266966835, "test",
'3',1266968068, "test",
'3',1266969797, "test",
'3',1267005658, "test",
'2',1267006399, "test",
'2',1266797836, "test",
'3',1266957673, "test",
'2',1266959468, "test",
'3',1266962012, "test",
'2',1266966835, "test",
'3',1266968068, "test",
'3',1266969797, "test",
'3',1267005658, "test",
'2',1267006399, "test",
'2',1266797836, "test",
'3',1266957673, "test",
'2',1266959468, "test",
'3',1266962012, "test",
'2',1266966835, "test",
'3',1266968068, "test",
'3',1266969797, "test",
'3',1267005658, "test",
'2',1267006399, "test",
'2',1267035316, "test");
for my $i (0 .. $#all_lines) { #$#all_lines
$cell = $all_lines[$i];
if($i %3 == 0){#C'est un Flag
if($cell == "2"){ #Sender
push @textSender, '['.date($all_lines[$i+1])->{"date-heure"}.']';#scalar(localtime($all_lines[$i+1]));
push @textSender, $all_lines[$i+2];
}
if($cell == "3"){#Receiver
push @textReceiver, '['.date($all_lines[$i+1])->{"date-heure"}.']';
push @textReceiver, $all_lines[$i+2];
}
}
}
my $adj = $mw -> Adjuster();
my $top_frame = $mw->Frame(
-background => "red"
)->pack(-side => 'top', -fill => 'both');
my $pane = $mw->Scrolled(
'Pane',
-scrollbars => 'w',
-sticky => 'nswe',
-background => '#CCCCFF',
)->pack( qw/ -fill both -anchor center -expand 1/ );
my $cadre = $pane->LabFrame(
-label => 'Mon titre cadre',
-background => '#CCCCFF',
)->pack( qw/ -fill both -anchor center -expand 1/ );
my $left_frame = $cadre->Frame(-background => "SkyBlue1")->pack(-side => 'left',
-fill => 'both');
my $right_frame = $cadre->Frame(-background => "SeaGreen3")->pack(-side => "right",
-fill => 'both');
$top_frame->Label( -text => "Messages",
-background => "red")->pack(-side => "top");
$left_frame->Label( -text => join("\n",@textSender),
# -width => 50,
# -height => 10,
-justify => 'left',
-wrap => 600,
-background => "SkyBlue1",
-foreground => "black")->pack(-side => 'top');
$right_frame->Label(-text => join("\n",@textReceiver),
-justify => 'right',
-wrap => 600,
-background => "SeaGreen3",
-foreground => "black")->pack(-side => 'top');
#Pour prendre en compte le scroll de la souris
$left_frame->bind("<Button-4>", sub { $left_frame->yviewScroll(1,"un
+its") });
$left_frame->bind("<Button-5>", sub { $left_frame->yviewScroll(-1,"u
+nits") });
my $bouton = $mw->Button (
-text => "Fermer",
-takefocus => 1,
-command => sub {exit;}
)->pack(-side => 'bottom', -fill => 'x', -ipady => 5);
MainLoop;
sub date {
my $time = shift || time; #$time par defaut vaut le time actuel
my ( $seconde, $minute, $heure, $jour, $mois, $annee, $jour_semaine, $jour_annee, $heure_hiver_ou_ete )
= localtime($time);
$mois += 1;
$annee += 1900;
# On rajoute 0 si le chiffre est compris entre 1 et 9
foreach ( $seconde, $minute, $heure, $jour, $mois, $annee ) {
s/^(\d)$/0$1/;
}
my %ladate = (
"date" => "$jour-$mois-$annee",
"heure" => "$heure:$minute:$seconde",
"date-heure" => "$jour/$mois/$annee $heure:$minute:$seconde",
"jour_semaine" => $jour_semaine,
"jour_annee" => $jour_annee,
"hiverOuEte" => $heure_hiver_ou_ete,
);
return \%ladate;
} |