[wxPython] problem with wxListCtrl - itemDataMap vs. DeleteItem

Greetings,

I'm using wxPython-2.3.2 on GNU/Linux (RedHat 7.3). I've hit what I believe
to be a bug in wxListCtrl, and I'm hoping someone out there could lend their
2 cents. I've scoured the mailing list archives, the sample code, and the
wxPyWiki to no avail.

My app receives a posted wxEvent at some point, and in the corresponding
method the app may add/update items. In lockstep with using
listCtrl.InsertStringItem and listCtrl.SetStringItem, the app also
adds/updates values in the itemDataMap structure. At the very end of this
code, I use this to re-sort the listCtrl:
    self.list.SortItems(self.GetColumnSorter())
So far so good.

Later, in response to a right-click popup menu item, I want to delete the
selected item(s). I use DeleteItem, of course. I also "del
self.itemDataMap[key]" so as to keep the listCtrl and the itemDataMap in
sync. Again, no problem.

But on the very next occurrance of the wxEvent mentioned above (in which I may
add/update items), at the tail end I hit that line of code that re-sorts the
list, and it raises "Mapping key not found" in
.../wxPython/lib/mixins/listctrl.py line 106 (the third statement of...):
    def __ColumnSorter(self, key1, key2):
        col = self._col
        ascending = self._colSortFlag[col]
        item1 = self.itemDataMap[key1][col]
        item2 = self.itemDataMap[key2][col]

It's somehow getting ahold of the key (key1's value) which had already been
removed from the itemDataMap.

If I don't delete the itemDataMap info for the listCtrl's deleted item, no
exception occurs. But then I'm failing to clean up old keys from
itemDataMap, and so that structure grows larger than necessary. Potentially
a LOT larger -- depends on how many deletions are happening.

Any workarounds? Any clues? Thanks in advance!

- Stephen

···

--
Stephen Bartlett, President
Bartlett Software, Inc.
http://www.bartlettsoftware.biz/