GetSelection() for wxListCtrl ?

The following will put all the selected (highlighted) rows into a list.
There is probably a more elegant way to do it but this works.

row = -1
selected_items = []
while 1:
  row = ListCtrl.GetNextItem(row, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED)
  if row==-1:
    break
  selected_items.append(row)

Steve

···

-----Original Message-----
From: Jacek Politowski [mailto:jp@jp.pl.eu.org]
Sent: Thursday, May 22, 2003 8:31 AM
To: wxPython-users@lists.wxwindows.org
Subject: [wxPython-users] GetSelection() for wxListCtrl ?

I have wxListCtrl and wxButton (remove).
I'd like to remove selected item from wxListCtrl

For wxListBox I've used foobar.Delete(foobar.GetSelection()), but for
wxListCtrl I can't find anything similar to GetSelection().

wxListCtrl have DeleteItem() method, which seems to work fine, but how
to pass item (row) ID to this method?

Is there any simple way for doing this?

TIA

--
Jacek Politowski

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

I've found much simplier way.

Instead of wxListCtrl one can use wxListView, which has
GetFirstSelection() and GetNextSelection() methods working as
expected. At least in my case - it simply works.

PS. Could You reply _under_ quoted text?

···

On Thu, May 22, 2003 at 11:32:38AM -0400, Zatz, Steve wrote:

The following will put all the selected (highlighted) rows into a list.
There is probably a more elegant way to do it but this works.

row = -1
selected_items =
while 1:
row = ListCtrl.GetNextItem(row, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED)
if row==-1:
  break
selected_items.append(row)

--
Jacek Politowski [rallypl.te@m.olsztyn]