[wxPython] How to delete items from ListBox

Hi,
I have ListBox defined with wxLB_EXTENDED option like

self.lb2 = wxListBox(self, 70, wxPoint(280, 50), wxSize(130, 300),
                       sampleList1, wxLB_EXTENDED)

How can I delete items from this ListBox?
I tried the following code but without any success.

          if (self.lb2.GetSelections()!=-1):
            for index2 in self.lb2.GetSelections():
               self.lb2.Delete((index2))

That works only if I choose one item at a time only- If I make a
multiple selection I receive an ivalid index in ListBox::Delete error.

Can you please help.
Thank you
Ladislav

How can I delete items from this ListBox?
I tried the following code but without any success.

          if (self.lb2.GetSelections()!=-1):
            for index2 in self.lb2.GetSelections():
               self.lb2.Delete((index2))

That works only if I choose one item at a time only- If I make a
multiple selection I receive an ivalid index in ListBox::Delete error.

Probably because the indexes are changing when you delete items. If one of
your selected items was closer to the end than the number of items deleted
then it will be an invalid index by the time you get to it. Maybe something
like this:

        selections = list(self.lb2.GetSelections())
        selections.reverse()
        for index in selections:
            self.lb2.Delete(index)

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!