how to get the text of a multichoicedialog?

Is there a way to get the text of the options chosen in a MultiChoiceDialog? I know that GetSelections() returns the indices, but I don't know if this will help me. I think I need to have the text instead, that way I can use the text to make SELECT statements on my database. I'm not sure how to do this with just the indices.

Thanks.

Hi John,

Is there a way to get the text of the options chosen in a
MultiChoiceDialog? I know that GetSelections() returns the indices, but
I don't know if this will help me.

Yes, it can. MultiChoiceDialog is usually shown using ShowModal(), and
this method is usually called right after the dialog creation. So, you
may want to do exactly as in the wxPython demo:

       lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
'grape', 'pineapple',
                'blueberry', 'raspberry', 'blackberry', 'snozzleberry',
                'etc', 'etc..', 'etc...' ]

        dlg = wx.MultiChoiceDialog( self,
                                   "Pick some fruit from\nthis list",
                                   "wx.MultiChoiceDialog", lst)

        if (dlg.ShowModal() == wx.ID_OK):
            selections = dlg.GetSelections()
            strings = [lst for x in selections]
            self.log.write("Selections: %s -> %s\n" % (selections, strings))

You don't keep any reference to the list of strings in the dialog,
because the variable "lst" is deleted (GC collected) when your methods
returns. I don't see any appealing reason to create a dialog inside
one method and call its ShowModal inside another method, so you don't
need to save a reference for the list of strings in the dialog.
Otherwise, you could try the "GetChildren" approach I outlined in a
previous post regarding TextEntryDialog.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

Andrea Gavana wrote:

           strings = [lst for x in selections]

Hmmm, I guess that's not a bad way to map the indices to the strings. So I take it that there is no native way for wxPython to get the strings itself? If not, this method seems fine.