Hello

This is really a low priority question, but been myself a perfectionist in UI design, I was wondering if there is a possibility to set the color Tablematrix uses when a cell/row is selected/in focus/highlighted (I do not know how to express it, sorry). Standard is a a quite old fashioned blue. I tried with $t->tagRow('active',$row); but this is actually not the right way. I can see the selection going blue and then getting the set color (not to mention that I have not implemented the way to reset the original color when another row is selected.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $arrayVar = {}; print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = "$row,$col"; } } print "Creating Table...\n"; sub colSub{ my $col = shift; return "OddCol" if( $col > 0 && $col%2) ; } sub rowSub{ my $row = shift; return "Oddrow" if( $row > 0 && $row%2) ; } my $t = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 6, -height => 6, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&coloring, -colstretchmode => 'last', -rowtagcommand => \&rowSub, -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se', -relief => 'ridge', -selectmode => 'extended', -selecttype=>'row', ); # Color definitions here: $t->tagConfigure('active', -bg => 'lightyellow', -fg => 'red', -relief + => 'sunken'); $t->pack(-expand => 1, -fill => 'both'); $t->focus; $t->configure (-state=>'disabled'); Tk::MainLoop; sub coloring { print "COLORING SELECTED ROW...\n"; my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; $t->tagRow('active',$row); }

In reply to Tk Tablematrix set color of selected row by Takamoto

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.