Hi, 

From: Ralf <lausianne / gmx.net>
Subject: disable a TkListbox
Date: Tue, 21 Jan 2003 17:55:40 +0900
Message-ID: <3e2d09b1$1 / epflnews.epfl.ch>
> I couldn't figure out how to disable a TkListbox.
> What I expected was something like
> 	list_box.configure('state' => 'disabled')
> .... as for TkText, for example.

Like this ?
-------------------------------------------------------------
#!/usr/bin/env ruby
require 'tk'

f = TkFrame.new.pack

lbox = TkListbox.new(f,'selectmode'=>'multiple').pack('side'=>'left')

['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 
 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn'].each{|term|
  lbox.insert 'end',term
}

lbox.yscrollbar(TkScrollbar.new(f).pack('side'=>'left', 'fill'=>'y'))

nultag = ['{}']  # depend on a bug of TkListbox#bindtags
tags = lbox.bindtags
select = []

f = TkFrame.new.pack

TkButton.new(f,'text'=>'enable',
             'command'=>proc{
                select.each{|idx| lbox.selection_set(idx) }
                lbox.bindtags(tags)
              }).pack('side'=>'left')

TkButton.new(f,'text'=>'disable',
             'command'=>proc{
                select = lbox.curselection
                lbox.selection_clear(0,'end')
                lbox.bindtags(nultag)
              }).pack('side'=>'left')

Tk.mainloop
-------------------------------------------------------------
-- 
                                  Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)