[Tutor] passing widget to callback before defined

vicki@stanfield.net vicki@stanfield.net
Thu Feb 27 15:51:02 2003


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.

----------------------------------
callback=SimpleCallback(CommandCallback,Listbox1)
Listbox1=Pmw.ScrolledListBox(Frame3,
            selectioncommand=callback,
            listbox_height=1, labelpos='w',
            label_text='Commands',
            items=("06", "09"))
Listbox1.pack()
---------------------------------

For the record, the callback looks something like this:

----------------------------------
def CommandCallback(Listbox1)
index=Pmw.ScrolledListBox.getcurselection(self.Listbox1)
---------------------------------

Regards,
--vicki