[wxPython] Question about ListCtrl:GetNextItem

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Question about ListCtrl:GetNextItem

Stephen Pitts
I'm trying to iterate through all of the selected items in a ListCtrl.
If I select the top item, the following code prints the name of the
bottom item repeatedly until I Ctrl-C the program. If I select any other
item, I get 0 returned as the item. Does anyone have any ideas?

        def OnMoveButton(self, event):
                sCount = self.EntrantList.GetSelectedItemCount()
                if sCount == 0:
                        errorDialog = wxMessageDialog(self, "Please select entrants to move.",
                                "Pairplus Export Wizard", style = wxICON_EXCLAMATION)
                        errorDialog.ShowModal()
                        return
               
                # what entrants are selected
                section = self.TourneyTree.GetPyData(self.TourneyTree.GetSelection())
               
                item = self.EntrantList.GetNextItem(-1, state =  wxLIST_STATE_SELECTED)
                while item != -1:
                        entrant = section.Entrants[self.EntrantList.GetItemData(item)]
                        print entrant.FirstName, entrant.LastName
                        previtem = item
                        item = self.EntrantList.GetNextItem(previtem, wxLIST_NEXT_BELOW, wxLIST_STATE_SELECTED)
--
Stephen Pitts
[hidden email]
webmaster - http://www.mschess.org

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users