I'm not entirely sure why that doesn't work, but I think it might have something to do with your resetting the self.itemDataMap variable. I wrote the following quick and dirty script and it works:
import wx
import wx.lib.mixins.listctrl as listmix
########################################################################
class SortableListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
""""""
#----------------------------------------------------------------------
def __init__(self, parent):
"""Constructor"""
wx.ListCtrl.__init__(self, parent, size=(-1,100),
style=wx.LC_REPORT|wx.BORDER_SUNKEN)
listmix.ListCtrlAutoWidthMixin.__init__(self)
########################################################################
class MyForm(wx.Frame):
#----------------------------------------------------------------------
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "List Control Tutorial")
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
self.index = 0
data = {1: ["Dr appointment", "05/06/2014", ""],
2: ["Meeting", "08/22/2013", "Board Room"]
}
self.list_ctrl = SortableListCtrl(panel)
self.list_ctrl.InsertColumn(0, 'Subject')
self.list_ctrl.InsertColumn(1, 'Due')
self.list_ctrl.InsertColumn(2, 'Location', width=125)
index = 0
for d in data:
print data[d][0]
print data[d][1]
self.list_ctrl.InsertStringItem(index, data[d][0]),
self.list_ctrl.SetStringItem(index, 1, data[d][1])
self.list_ctrl.SetStringItem(index, 2, data[d][2])
index += 1
btn = wx.Button(panel, label="Update")
btn.Bind(wx.EVT_BUTTON, self.updateListCtrl)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.list_ctrl, 1, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.CENTER|wx.ALL, 5)
panel.SetSizer(sizer)
#----------------------------------------------------------------------
def updateListCtrl(self, event):
"""
"""
self.list_ctrl.DeleteAllItems()
data = {1: ["Tennis", "09/06/2013", ""],
2: ["Lunch", "08/15/2013", "Chick-fil-a"]
}
index = 0
for d in data:
print data[d][0]
print data[d][1]
self.list_ctrl.InsertStringItem(index, data[d][0]),
self.list_ctrl.SetStringItem(index, 1, data[d][1])
self.list_ctrl.SetStringItem(index, 2, data[d][2])
index += 1
#----------------------------------------------------------------------
# Run the program
if __name__ == "__main__":
app = wx.App(False)
frame = MyForm()
frame.Show()
app.MainLoop()
Try commenting out the self.itemDataMap at the end of OnselectADP. If that doesn't work, then the next thing I would try is removing the global stuff.