[wxPython] Listview funkiness

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Listview funkiness

Stephen Pitts
I'm using GetNextItem to try and enumerate the selected items in
a list, like this:

def OnMoveButton(self, event):
        item = self.EntrantList.GetNextItem(-1, state = wxLIST_STATE_SELECTED)
        while(item != -1):
                itemObj = self.EntrantList.GetItem(item)
                print itemObj.m_text
                prevItem = item
                item = self.EntrantList.GetNextItem(prevItem, state = wxLIST_STATE_SELECTED)

The problem is that itemObj.m_text is always None. Since I can't use
Get/SetPyData with the ListView, I've made the first column into the key
of a dictionary with the objects that my listview represents. Does
anyone have any better ideas or any idea of why this isn't working?
--
Stephen Pitts
[hidden email]
webmaster - http://www.mschess.org

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



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Listview funkiness

Robin Dunn


> I'm using GetNextItem to try and enumerate the selected items in
> a list, like this:
>
> def OnMoveButton(self, event):
> item = self.EntrantList.GetNextItem(-1, state = wxLIST_STATE_SELECTED)
> while(item != -1):
> itemObj = self.EntrantList.GetItem(item)
> print itemObj.m_text
> prevItem = item
> item = self.EntrantList.GetNextItem(prevItem, state =
wxLIST_STATE_SELECTED)
>
> The problem is that itemObj.m_text is always None. Since I can't use
> Get/SetPyData with the ListView, I've made the first column into the key
> of a dictionary with the objects that my listview represents. Does
> anyone have any better ideas or any idea of why this isn't working?

I'm guessing that m_text isn't set because you're in report mode and there
are actually multiple items for each row and it doesn't know which to get
for you...   (And is it actually None or is it an empty string?)

The wxListCtrl does have SetItemData and GetItemData methods that let you
associate an integer with each item.  Maybe this would be better for your
dictionary keys, (creating a unique value for each item.)

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



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