Hi nkoehring, wie von dir vermutet passiert das nur bei den flags ``wx.LC_SORT_ASCENDING`` und ``wx.LC_SORT_DESCENDING``, also beim sortieren. Das ganze ist ein Bug den ich vor einiger Zeit auch entdeckt habe und mich ehrlich frage wieso das ganz so viele Jahre unentdeckt geblieben ist!?! Ich hoffe es leigt nicht an den ``InsertStringItem``-"workarounds", die ja doch heufiger als Antwort auftauchen
Die originale Implementation (in wx._controls):
Code: Alles auswählen
def Append(self, entry):
'''Append an item to the list control. The entry parameter should be a
sequence with an item for each column'''
if len(entry):
if wx.USE_UNICODE:
cvtfunc = unicode
else:
cvtfunc = str
pos = self.GetItemCount()
self.InsertStringItem(pos, cvtfunc(entry[0]))
for i in range(1, len(entry)):
self.SetStringItem(pos, i, cvtfunc(entry[i]))
return pos
Wenn Ihr genau hischaut seht ihr den fehler

self.ItemCount bzw. self.GetItemCount() als position für `SetStringItem` zu nehmen ist mehr als dumm
hier mal der Bugfix:
Code: Alles auswählen
def Append(self, entry):
'''Append an item to the list control. The entry parameter should be a
sequence with an item for each column'''
if len(entry):
if wx.USE_UNICODE:
cvtfunc = unicode
else:
cvtfunc = str
pos = self.InsertStringItem(self.GetItemCount(), cvtfunc(entry[0]))
for i in range(1, len(entry)):
self.SetStringItem(pos, i, cvtfunc(entry[i]))
return pos
Und hier das diff von mir für den "aktuellen" trunk:
Code: Alles auswählen
Index: src/_listctrl.i
===================================================================
--- src/_listctrl.i (Revision 51362)
+++ src/_listctrl.i (Arbeitskopie)
@@ -821,8 +821,7 @@
cvtfunc = unicode
else:
cvtfunc = str
- pos = self.GetItemCount()
- self.InsertStringItem(pos, cvtfunc(entry[0]))
+ pos = self.InsertStringItem(self.GetItemCount(), cvtfunc(entry[0]))
for i in range(1, len(entry)):
self.SetStringItem(pos, i, cvtfunc(entry[i]))
return pos
OT: Naja, an einigen stellen ist wxPyhon doch schon ziemlich kaputt, leider. Und wirklich kooperativ sind die core devs insofern nicht, als das viele Bugs mit FERTIGEN patches im bugtracker seit Jahren vergammeln. Entschuldigt mein Unmut, aber ein wenig schade ist es schon
