[Tutor] passing widget to callback before defined

Abel Daniel abli@freemail.hu
Fri Feb 28 08:44:03 2003


vicki@stanfield.net (vicki@stanfield.net) wrote:
> What do you do when you have to define the callback
> when the item is created (ScrolledListBox has the
> selectioncommand argument) and you want to pass the
> name of the item to the callback. As shown below, the
> selectioncommand needs to use the name Listbox1 before
> the Listbox is actually defined.
1) Create Listbox
2) make callback
3) set callback as selectioncommand of the listbox

Like this:
> 
> ----------------------------------
> Listbox1=Pmw.ScrolledListBox(Frame3,
>             listbox_height=1, labelpos='w',
>             label_text='Commands',
>             items=("06", "09"))
  callback=SimpleCallback(CommandCallback,Listbox1)
  # ^^ moved here
  Listbox1.configure(selectioncommand=callback)
> Listbox1.pack()

abli