You can set attributes on different regions of a text widget (including but not restricted to lines) using tags. To set a tag, you need something like:
<text widget path> tag add <tag name> <start index> <end index>. In your case I gather the text widget path is $k. Now let's say you had line number X that you wanted to set a color for. That would be:
$k tag add <tag name> X.0 X.end, to get the whole line. X isn't the same as $spin because the lines are numbered from 1, not 0. Now you would have a tag specified that corresponded to that line. You use the tag configure statement to change/set the color:
$k tag configure <tag name> -background red.
_________________
Bob Rashkin
rrashkin@csc.com