Hi guys, I'm trying to create a data table on perl Tk. I want to disable some cells based on the values entered on the previous cells. I'm not sure if that is possible so I created a button so the user can click after he enters all his values and then, it would disable the unwanted cells. Eventhough that would be useless, I still can't seem to disable those cells. Also, I want to link the text variables to a pop-up help window. My code is:
use Tk; use Tk::TableMatrix; use Tk::Text; use Tk::Dialog; use Data::Dumper qw( DumperX); my $mw = MainWindow->new; $nst = 3; my $arrayVar = {}; foreach my $row (0..10){ foreach my $col (0..$nst){ $arrayVar->{"0,0"} = "Variables"; #link to pop-up help window $arrayVar->{"0,$col"} = "r".($col/2+.5); if ($col%2 == 0) { $arrayVar->{"0,$col"} = "s".($col/2); } } } $mw->Button(-text => "Update", -command => \&update_table)->pack(-side + => 'bottom', -anchor => 'w'); my $t = $mw->Scrolled('TableMatrix', -rows => 10, -cols => $nst, -width => 6, -height => 6, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -selectmode => 'extended', -resizeborders => 'both', -titlerows => 1, -titlecols => 1, -bg => 'white', # -state => 'disabled' # -colseparator => "\t", # -rowseparator => "\n" ); $t->tagConfigure('active', -bg => 'gray90', -relief => 'sunken'); $t->tagConfigure( 'title', -bg => 'gray85', -fg => 'black', -relief => + 'sunken'); # $t->bind("<Any-Enter>", sub { $t->focus }); $t->pack(-expand => 1, -fill => 'both'); Tk::MainLoop; sub update_table { if ($arrayVar->{"6,$col"} == 1) { $arrayVar->{"7..9,$col"}->tagConfigure(-state => 'normal'); $arrayVar->{"7..9,$col"}->tagConfigure(-state => 'disabled'); $arrayVar->{"7..9,$col"}->tagConfigure(-state => 'disabled'); } # foreach my $row (1..10){ # foreach my $col (1..$nst){ # unless ($arrayVar->{"$row,$col"} =~ /[0-9]+/) { # $D = $mw->Dialog( # -title => 'Warning', # -text => "Please enter a valid number for $row,$col +!\n", # -font => 'Times 10', # -default_button => 'OK'); #$D->bell; #$D->Show; # } # } # } }
Any suggestions?

In reply to Tk ::TableMatrix by lil_v

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.