#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; $Tkx::TRACE = 64; use Tkx; Main( @ARGV ); exit( 0 ); sub Main { Tkx::package_require("Tktable"); my $mw = Tkx::widget->new("."); my %tablecontents ; my $table = $mw->new_table( -rows => 4, -cols => 4, -cache => 1, -variable => \%tablecontents, ); $table->g_pack( -fill => 'both', -expand => 1 ); my $popb = $mw->new_button( -text => 'Populate' ); $popb->configure( -command => [ \&populate_table, $table , \%tablecontents ], ); $popb->g_pack; $mw->new_button( -text=>"Finish", -command=> [ \&record_data_exit , $mw, $table, \%tablecontents ], )->g_pack(); Tkx::MainLoop(); } sub populate_table { my( $table, $hash ) = @_; dd[ $hash ]; my $rows = $table->cget('-rows') ; my $cols = $table->cget('-cols') ; for my $row ( 0 .. $rows ){ for my $col ( 0 .. $cols ){ $table->set("$row,$col", "yo $row, $col oy" ); } } dd[ $hash ]; return; } sub record_data_exit { my( $mw, $table, $hash ) = @_; dd[ $table->get( qw/ topleft bottomright / ) ]; my $rows = $table->cget('-rows') ; my $cols = $table->cget('-cols') ; for my $row ( 0 .. $rows ){ for my $col ( 0 .. $cols ){ dd[ $table->get( "$row,$col" ) ]; } } dd[ $hash ]; $mw->g_destroy; };