Disable a TkListbox

Hi,
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.
Could you give me a hint for this one, please? Thanks!
Ralf.

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)

Thanks a lot! This is more than I was hoping for. Wonderful.
So there is no Ruby binding for the -state option yet?
(http://tmml.sourceforge.net/doc/tk/listbox.html)
Is work on Ruby/Tk still going on, or do people tend towards other GUIs?
Cheers, Ralf.

Thanks a lot! This is more than I was hoping for. Wonderful.
So there is no Ruby binding for the -state option yet?
(http://tmml.sourceforge.net/doc/tk/listbox.html)
Is work on Ruby/Tk still going on, or do people tend towards other GUIs?
Cheers, Ralf.

Hi,

···

From: Ralf lausianne@gmx.net
Subject: Re: disable a TkListbox
Date: Tue, 21 Jan 2003 21:16:24 +0900
Message-ID: 3e2d3687$1@epflnews.epfl.ch

So there is no Ruby binding for the -state option yet?
(Tk Reference Manual: listbox)

You can use the option, if your Tcl/Tk library,
which is linked to Ruby, supports the option. :slight_smile:
Check Tk::TK_VERSION .
It is a version of yoru Tk which works on Ruby/Tk.
For example, Tcl/Tk8.0 doesn’t have the option.
So, Ruby/Tk which uses Tcl/Tk8.0 cannot use the option.

If new features of new Tcl/Tk are such new keys only,
probably Ruby/Tk with new Tcl/Tk can support the option.
If add new widgets, we need new class definition to use
the widgets properly.
Of course, if you use Tk.tk_call(…),
there are no feature that cannot be controlled by Ruby/Tk.

Is ‘-state’ option supported on Tcl/Tk8.4 ?
I heard there are some troubles to use Tcl/Tk8.4k for Ruby/Tk.
I’m sorry but now I have no time to check and fix the troubles.

                              Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)