Attached is a little Spike that Chet and I are doing. It is a
dictionary browser, with a listbox of keys and a textbox of values.

The things we think are odd or don't know how to do are:

1. You can ask the listbox for the index of its selection, but not its
selection.

2. You have to delete the text from the textbox by naming its
beginning 1.0 and its end 'end'.

3. The listbox doesn't expand to fill the window width

4. The widgets don't resize when you resize the window.

We'll be grateful for better ways to have done thing, hints, notions,
or general encouragement and commiseration.

Thanks,

Ron

require 'tk'
require 'tkencoding'
require 'tkafter'

dictionaryBrowser = TkRoot.new {|w|
  title("Dictionary Browser")
  #positionWindow(w)
}

dictionaryListbox = nil
TkFrame.new(dictionaryBrowser, 'borderwidth'=>10) {|w|
  s = TkScrollbar.new(w)
  dictionaryListbox = TkListbox.new(w) {
    setgrid 1
    width  10
    height 12
    selectmode 'single'
    yscrollcommand proc{|first,last| s.set first,last}
  }
  s.command(proc{|*args| dictionaryListbox.yview *args})
  s.pack('side'=>'right', 'fill'=>'y')
  dictionaryListbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')

 textBox = TkText.new(dictionaryBrowser, 'height'=>10)
 textBox.pack
 
 dictionary = { 'a' => 'A is for apple, so red and sweet',
    'b' => 'B is for bee, so bumbling' }
    dictionary.keys.each { |key|
        dictionaryListbox.insert('end', key) }

dictionaryListbox.bind('ButtonRelease-1', proc{
    sel = dictionaryListbox.curselection
    selection = dictionaryListbox.get(sel)
    textBox.delete('1.0','end')
    textBox.insert('1.0', dictionary[selection])})


Tk.mainloop


Ronald E Jeffries
http://www.XProgramming.com
http://www.objectmentor.com