Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Tk Tablematrix configure word in a cell

by welle (Beadle)
on May 06, 2012 at 08:05 UTC ( #969124=perlquestion: print w/replies, xml ) Need Help??
welle has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I am adapting an old GUI of mine, changing data visualization from a text to a tablematrix widget. I need to colorize single words. That was pretty easy in a text widget.

$kwic->tagAdd('color', "$line.$word_pos_start", "$line_kwic.$word_pos +_end");

Is this possible in a tablematrix cell? (as far as I now i can only tag a single cell (tagCell).

Replies are listed 'Best First'.
Re: Tk Tablematrix configure word in a cell
by stefbv (Deacon) on May 06, 2012 at 09:03 UTC
    That was pretty easy in a text widget.

    Then try to embed a Text widget in the cell.

    Update: A quick demo:

    use strict; use warnings; use Tk; use Tk::TableMatrix; my $top = MainWindow->new; my $arrayVar = {}; foreach my $row ( 0 .. 7 ) { foreach my $col ( 0 .. 3 ) { $arrayVar->{"$row,$col"} = "r$row,c$col"; } } my $tmx = $top->Scrolled( 'TableMatrix', -rows => 7, -cols => 3, -variable => $arrayVar, -resizeborders => 'both', -titlerows => 1, -bg => 'white', ); #--- my $c = 2; foreach my $r ( 1 .. 7 ) { my $tc = build_text($top); $tmx->windowConfigure( "$r,$c", -sticky => 's', -window => $tc ); } $tmx->colWidth( $c, 20 ); $tmx->pack( -expand => 1, -fill => 'both' ); Tk::MainLoop; sub build_text { my $frame = shift; my $tc = $frame->Text( -bg => 'white', ); $tc->tagConfigure( 'blue', -foreground => 'blue', ); $tc->insert('insert', 'Text with '); $tc->insert('insert', ' blue ', 'blue'); $tc->insert('insert', ' word '); return $tc; }

      Perfect! Thank you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://969124]
Approved by stefbv
[ambrus]: I hope Corion or some other admin is here and can check the logs to see what the problem is.
[mz2255]: I wish I had an online shop but sadly no. The title field definitly wasn't short, had a perl module in the title with 5-6 additional words.
[ambrus]: you can also try to just post again in case it was some intermittent error
[mz2255]: Tried again, denied. Maybe my code is just so bad the site refuses to post it.
[marto]: no, there's a bug, sometimes...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2017-10-19 15:36 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (255 votes). Check out past polls.