package require Tk
proc listbox'disable {w {index ""}} {
if {$index eq ""} {
foreach i [$w curselection] {
if {[$w itemcget $i -selectbackground] eq [$w cget -background]} {
$w selection clear $i
}
}
} else {
$w itemconfig $index -selectbackground [$w cget -background] \
-selectforeground [$w cget -foreground]
}
}#----------------------- Testing demo (displays the selected indices in the titlebar): set data {Head1 a b c Head2 d e f}
pack [listbox .lb -listvar data -selectmode extended]
foreach i {0 4} {listbox'disable .lb $i}
bind .lb <<ListboxSelect>> {listbox'disable %W; wm title . [%W curselection]}Category Example - Arts and crafts of Tcl-Tk programming
