[wxPython-users] get wxListCtrl from wxListItem?
Werner F. Bruhin
werner.bruhin at free.fr
Tue Jan 2 12:54:34 PST 2007
Hi Andrew,
What about SetItemData and GetItemData?
wxListCtrl::SetItemData
bool SetItemData(long item, long data)
Associates application-defined data with this item.
Werner
Pangborn, Andrew (ext. 324) wrote:
> listCtrl.SetStringItem() always seems to return '1'. Not sure if this is meant to represent "True" for a successful addition to the list? It appears that SetStringItem is a wxPython specific function, so I can't find any details about what it's supposed to return in the wx module docs.
>
Have a look at the end of e.g. the wxWidgets doc for SetItem:
wxListCtrl::SetItem
bool SetItem(wxListItem& info)
long SetItem(long index, int col, const wxString& label, int imageId = -1)
Sets information about the item.
...
wxPython note: In place of a single overloaded method name, wxPython
implements the following methods:
SetItem(item)
Sets information about the given wxListItem.
SetStringItem(index, col, label, imageId)
Sets a string or image at a given location.
> I think I've found a solution though. I'm using a lambda on my binding function and passing it the python data object that I want to modify.
>
> So now I have "list_control.Bind(wx.EVT_LIST_END_LABEL_EDIT, lambda event: self.OnEditVector(event,node))", where "node" is the data object I'm trying to modify.
>
> and a relatively simple event handling function:
>
> def OnEditVector(self,event,node):
> index = event.GetColumn()
> value = event.GetText()
> node.data[index] = float(value)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
>
>
>
More information about the wxpython-users
mailing list