use strict;
use warnings;
use Tkx;
use Tcl;
Tkx::package_require("Tktable");

my $interp = Tcl->new;
my $mw = Tkx::widget->new(".");
my %hash;
$hash{'2,0'} = "Before tie";
tie %hash, "Tcl::Var", Tkx::i::interp(), "tclarray";
$interp->SetVar2("tclarray", "0,0", "Set with");
$interp->SetVar2("tclarray", "0,1", "Tcl");
$interp->SetVar2("tclarray", "0,2", "interp");
Tkx::i::interp->SetVar2("tclarray", "1,0", "Set with");
Tkx::i::interp->SetVar2("tclarray", "1,1", "Tkx");
Tkx::i::interp->SetVar2("tclarray", "1,2", "interp");
$hash{'3,0'} = "After tie";
my $t = $mw->new_table(
    -rows => 5,
    -cols => 3,
    -cache => 1,
    -variable => "tclarray",
    -sparsearray => 0,
);
$t->g_pack;
my $b = $mw->new_button(
  -text => "Show data",
  -command => \&show_data,
);
$b->g_pack;
sub show_data {
  print "show data\n";
  for my $cell (sort keys %hash) {
    print "cell=$cell $hash{$cell}\n";
  }
  return;
}
Tkx::MainLoop()
