Hi,
I’ve a wx.ListCtrl like
class MyListCtrl(wx.ListCtrl):
def __init__(self, parent, dataSource):
wx.ListCtrl.__init__(self, parent,
style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.LC_VIRTUAL)
.........
with this
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected)
and
def OnItemSelected(self, evt):
self.item = evt.GetItem()
print "Item selected:", self.item.GetText()
strSelected =item.GetText()
wx.MessageBox(strSelected,"Item selected:", wx.OK)
return self.item
How I can call the def OnItemSelected from a button in the frame?
I try so
class MyFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, -1,
“Virtual wx.ListCtrl”,
size=(600,400))
panel = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
.....................
self.list = MyListCtrl(panel, DataSource())
self.cmdEdit = wx.Button(panel, -1, '&Edit', size=(70, 30))
self.Bind(wx.EVT_BUTTON, self.fctEdit, self.cmdEdit)
def fctEdit(self,event):
id = self.list.OnItemSelected(self)
print id
Python return this
AttributeError: ‘MyFrame’ object has no attribute ‘GetItem’
What is wrong?
Beppe