Updated 2012-07-09 16:16:26 by RLE

GPS: This is a quick proc I came up with for my Grindweb project, which paints the background of a listbox in alternating colors. lvirden was asking about how to do such a thing (probably from the recent discussion of theme support in Tk). So, here's a toy for everybody.
 #Copyright 2003 George Peter Staplin
 #You may use this under the same terms as Tcl.
 proc alternate.listbox.colors {listWin colList} {
  if {![winfo exists $listWin]} {
   return -code error {invalid window path}
  }
  set listWinEnd [$listWin index end]
  set colCount 0
  set colListLength [llength $colList]
  for {set i 0} {$i < $listWinEnd} {incr i} {
   $listWin itemconfigure $i -background [lindex $colList $colCount]
   incr colCount
   if {$colCount >= $colListLength} {
    set colCount 0
   }
  }
 }

Use it like so:
 pack [listbox .l]
 .l insert end Hello World George likes programming sometimes but lately dislikes it
 alternate.listbox.colors .l [list white peachpuff]