BWidget::ComboBox

A BWidget ComboBox example:

  package require BWidget
  pack [ComboBox .a -values {Bach Beethoven Brahms} -modifycmd {compo .a}]
  proc compo {w} { puts "Your Favourite Composer is [$w get]"}

Will present just such a combo box. However the following proc will cause an error (in 8.4 and still in 8.5):

  proc compo {w} { puts "Your Favourite Composer is [$w get]"; destroy .a}

because the widget is destroyed before the BWidget code finishes handling the event. (I wanted to use the selection to start a procedure and prevent any more use of the widget.)

The 'work round' is a tiny change to the modifycmd:

  pack [ComboBox .a -values {Bach Beethoven Brahms} -modifycmd {after 0 {compo .a}}]

the 'after' in the command allows BWidget to tidy itself up before proc compo is started.