spx2 has asked for the wisdom of the Perl Monks concerning the following question:

I have encountered some problems along the way. I am using POE and Tk together so this may be the problem.

1)If I'm using Tk::TableMatrix I have no problems regarding Buttons, they are showed on the screen I'm very happy... BUT , the -variable property that is used when I create the Tk::TableMatrix needs to fit my needs as I'm using POE,so I choose to have it in  $heap->{tablearray}. If I don't define it before using it it's no problem because it's autovivified anyway ,however, if I do define it before I use it ,like this $heap->{tgarray},I get this very strange error:

bad table index "0": must be active, anchor, end, origin, topleft, bottomright, @x,y, or <row>,<col> at /usr/lib/perl5/Tk.pm line 247./code>

2)I have tried to isolate the problem. My conclusion was that Tk::TableMatrix for some reason does not let me modify text entries in cells at run-time. The testacase that supports this ideea is the following:

use strict; use warnings; use Tk; use Tk::BrowseEntry; use Tk::TableMatrix; use Data::Dumper qw( DumperX); my $top = MainWindow->new; my $stuff = {}; my $tg = $top->Scrolled( 'TableMatrix', -rows => 21, -cols => 11, -width => 10, -height => 20, -titlerows => 1, -titlecols => 1, -variable => $stuff, -selectmode => 'extended', -resizeborders => 'both', -titlerows => 1, -titlecols => 1, -bg => 'white', )->pack( -expand => 1, -fill=>'both' ); $tg->tagConfigure('active', -bg => 'gray90', -relief => 'sunken') + ; $tg->tagConfigure('title', -bg => 'gray85', -fg => 'black', -relief => + 'sunken') ; $top->Button( -text=>'modify', -command=> sub { $stuff->{'3,3'} = 'asfasf'; }, )->pack; Tk::MainLoop;

Replies are listed 'Best First'.
Re: problems using Tk::TableMatrix
by zentara (Cardinal) on Aug 24, 2007 at 12:52 UTC
    If you look at it closely, if you move your x scrollbar after the modify, it shows up. This is an update problem, and here is a code trick (hack) to make your script work. It forces the TableMatrix to run thru it's cells and update them. Shown 2 ways.
    $top->Button( -text=>'modify', -command=> sub { $stuff->{'3,3'} = 'asfasf'; #&TMRefresh($tg); $tg->configure(-padx =>( $tg->cget(-padx))); }, )->pack; Tk::MainLoop; sub TMRefresh { #Required input TableMatrix object. #use to force matrix to update, a code trick return if (!$_[0]); $_[0]->configure(-padx =>($_[0]->cget(-padx))); }

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: problems using Tk::TableMatrix
by Anonymous Monk on Aug 24, 2007 at 10:52 UTC
    your code doesn't demonstrate your error