my $mw1 = MainWindow->new;
$mw1->geometry("600x350");
$mw1->resizable( 1, 1 );
$mw1->title("Ultimos 10 ");
my $fichero = "C:\\DoNotCopyToEB\\old.dat";
open FICHERO, "$fichero";
my @linea = <FICHERO>;
$mw1->Label( -text => "Informe", -font => 'ARIAL', -foreground => 'DARK BLUE' )->pack();
my $frame = $mw1->Frame()->pack();
my $T = $frame->Table( -columns => 8, -rows => 11, -fixedrows => 1, -scrollbars => 'oe', -relief => 'raised' );
#* * * * * * * ENCABEZADOS * * * * * *
my $tmp_label = $frame->Label( -text => " N° ", -justify => 'center', -width => 3, -relief => 'raised' );
$T->put( 0, 1, $tmp_label );
$tmp_label = $frame->Label( -text => "FECHA ", -width => 12, -relief => 'raised' );
$T->put( 0, 2, $tmp_label );
$tmp_label = $frame->Label( -text => "HORA ", -width => 10, -relief => 'raised' );
$T->put( 0, 3, $tmp_label );
$tmp_label = $frame->Label( -text => "L ", -width => 10, -relief => 'raised' );
$T->put( 0, 4, $tmp_label );
$tmp_label = $frame->Label( -text => "Lo ", -width => 10, -relief => 'raised' );
$T->put( 0, 5, $tmp_label );
$tmp_label = $frame->Label( -text => "PR ", -width => 15, -relief => 'raised' );
$T->put( 0, 6, $tmp_label );
$tmp_label = $frame->Label( -text => "MA ", -width => 10, -relief => 'raised' );
$T->put( 0, 7, $tmp_label );
$tmp_label = $frame->Label( -text => "file ", -width => 8, -relief => 'raised' );
$T->put( 0, 8, $tmp_label );
#* * * * * * * * LLENADO DE TABLA* * * * * * * * * *
for ( $i = 1; $i < 11; $i++ ) {
my @datos = split( /\s+/, $linea[ $i - 1 ] ); #/\s/ es un espacio en blanco (space)
$lat[$cont] = sprintf( "%5.2f", $datos[1] );
$lon[$cont] = sprintf( "%5.2f", $datos[2] );
$dep[$cont] = sprintf( "%3.1f", $datos[6] );
$sta[$cont] = $datos[9];
$m1mag[$cont] = sprintf( "%4.2f", $datos[3] );
$mag{Ms} = $datos[16];
#print "Ms $datos[16] \n";
$mag{Mw} = $datos[20];
#print "Mw $datos[20] \n";
$mag{Ml} = $datos[14];
#print "Ml $datos[14] \n";
$mag{Mwp} = $datos[18];
#print "Mwp $datos[18] \n";
$mag{Mb} = $datos[12];
#print "Mb $datos[12] \n";
foreach my $value ( sort { $mag{$a} cmp $mag{$b} } keys %mag ) {
#print "$value $mag{$value}\n";
$m1mag[$cont] = sprintf "%4.2f", $mag{$value};
$m1typ[$cont] = $value;
}
$origen[$cont] = $datos[0];
my @utc = gmtime( $origen[$cont] );
#$origen[$cont] = int($origen[$cont]);
$yr[$cont] = sprintf "%4d", $utc[5] + 1900;
$mo[$cont] = sprintf "%02d", $utc[4] + 1;
$mday[$cont] = sprintf "%02d", $utc[3];
$hr[$cont] = sprintf "%02d", $utc[2];
$mi[$cont] = sprintf "%02d", $utc[1];
$se[$cont] = sprintf "%02d", $utc[0];
my $A = $mday[$cont] . "/" . $mo[$cont] . "/" . $yr[$cont];
my $B = $hr[$cont] . ":" . $mi[$cont] . ":" . $se[$cont];
$tmp_label
= $frame->Label( -text => $i, -padx => 2, -anchor => 'center', -background => 'white', -relief => "groove" );
$T->put( $i, 1, $tmp_label );
$tmp_label
= $frame->Label( -text => $A, -padx => 2, -anchor => 'center', -background => 'white', -relief => "groove" );
$T->put( $i, 2, $tmp_label );
$tmp_label
= $frame->Label( -text => $B, -padx => 2, -anchor => 'center', -background => 'white', -relief => "groove" );
$T->put( $i, 3, $tmp_label );
$tmp_label = $frame->Label(
-text => $lat[$cont],
-padx => 2,
-anchor => 'center',
-background => 'white',
-relief => "groove"
);
$T->put( $i, 4, $tmp_label );
$tmp_label = $frame->Label(
-text => $lon[$cont],
-padx => 2,
-anchor => 'center',
-background => 'white',
-relief => "groove"
);
$T->put( $i, 5, $tmp_label );
$tmp_label = $frame->Label(
-text => $datos[6],
-padx => 2,
-anchor => 'center',
-background => 'white',
-relief => "groove"
);
$T->put( $i, 6, $tmp_label );
$tmp_label = $frame->Label(
-text => $m1mag[$cont],
-padx => 2,
-anchor => 'center',
-background => 'white',
-relief => "groove"
);
$T->put( $i, 7, $tmp_label );
$tmp_label = $frame->Label( -text => "FILE", -padx => 2, -anchor => 'center', -background => 'white',
-relief => "groove" );
$T->put( $i, 8, $tmp_label );
$tmp_label->bind('<Button-1>',\&sfile );
}
$T->pack();
my $button_frame = $mw1->Frame( -borderwidth => 4 )->pack();
$button_frame->Button(-text => "Salir", -padx => 30, -command => sub {exit})->pack();
close FICHERO;