mostrar el valor entero.
El problema está en la función show_cells(), la cual muestra solo los números. Mi idea es que muestre el valor completo. Lo he intentado mostrando con $_ pero no se muestra.
Using perl Syntax Highlighting
- #!/usr/bin/perl
- use warnings;
- use Tk;
- use Tk::Table;
- my $cols = 10;
- my $rows = 20;
- my %slct;
- # ------------------------------------------------------------------------
- sub show_cells {
- print "Selected Cells: ";
- foreach ( sort {$a <=> $b} (keys %slct)) {
- #################################################Aca esta la duda
- printf "%d,%d ",split (/\./,$_);
- }
- print "\n";
- }
- # ------------------------------------------------------------------------
- sub toggle_slct {
- my ($w, $t) = @_;
- my ($row, $col) = $t->Posn( $w );
- my $k = sprintf "%d.%02d",$row,$col;
- if ($slct{$k}) {
- $w->configure(-background => 'white');
- print "Row: $row Col: $col unselected\n";
- delete($slct{$k});
- } else {
- $w->configure(-background => 'grey');
- print "Row: $row Col: $col selected\n";
- $slct{$k} = 1;
- }
- }
- # ------------------------------------------------------------------------
- #
- # create the main window and frame
- #
- my $mw = new MainWindow();
- my $tableFrame = $mw->Frame(-borderwidth => 2,
- -relief => 'raised')->pack;
- #
- # allocate a table to the frame
- #
- my $table = $tableFrame->Table(-columns => 8,
- -rows => 10,
- -fixedrows => 1,
- -scrollbars => 'se',
- -relief => 'raised');
- #
- # column headings
- #
- foreach my $c ( 1 .. $cols) {
- my $hdr = "Row " . $c;
- my $tmp = $table->Label(-text => $hdr,
- -width => 6,
- -relief => 'raised');
- $table->put( 0, $c, $tmp );
- }
- #
- # populate the cells and bind an action to each one
- #
- foreach my $r ( 1 .. $rows ) {
- foreach my $c ( 1 .. $cols ) {
- my $data = $r . "," . $c;
- my $tmp = $table->Label(-text => "hola".$data, -padx => 2,
- -anchor => 'w',
- -background => 'white',
- -relief => 'groove');
- $tmp->bind('<Double-1>', [ \&toggle_slct, $table ]);
- $table->put( $r, $c, $tmp );
- }
- }
- $table->pack( -expand => 'yes', -fill => 'both');
- #
- # create the menu bar, and add the "show" and "exit" buttons
- #
- my $buttonBar = $mw->Frame( -borderwidth => 4 )->pack(-fill => 'y');
- my $showB = $buttonBar->Button(-text => "Show",
- -command => \&show_cells);
- my $exitB = $buttonBar->Button( -text => "Exit",
- -width => 10,
- -command => sub { exit });
- foreach ( $showB, $exitB ) {
- $_->pack(-side => 'left', -padx => 2 );
- }
- #
- # start it up
- #
- MainLoop();
Coloreado en 0.007 segundos, usando GeSHi 1.0.8.4
¿ Alguien me puede ayudar ?