Hello all!
I'm fighting with virtual Tree list control.
It should have ability to sort by any column.
I have managed to do it but annoying problem arise :
after sorting I should restore cursor position inside my tree on old record
but on new position in tree:
so here is code:
self.Bind(wx.EVT_LIST_COL_CLICK, self.onColumnClick)
...
def onColumnClick(self,evt):
''' save old selected item
sort
find old selected item and programmatically move cursor in new
position
'''
prev_item = self.GetSelection() # saving previously selected item
save_id = self.GetItemText(prev_item) # and his first column (primary key
in my case)
self.UnselectAll() # unselecting all records in tree
self.SortColumn(evt.GetColumn()) # it's my custom function which sorts by
column and repopulate virtual tree
# now restore previously saved position in new tree
# this custom function is searches new tree for save_id value in first
column and returns found item
newly_found_item =
self.recursiveFindItemByPydata(self.GetRootItem(),save_id)
if newly_found_item.IsOk():
self.SelectItem(newly_found_item,unselect_others=True)
# and here is problem:
# --------------------
# newly found record gets highlighted but previous position have nasty
black border around it and if I move cursor by Up or Down key
# then my tree navigation starts not from new record but from
previous one...
# why is that so???
# Dear wxwidget makers: can I have a
'SelectItem_WithNoBorderOnOldPositionAndWithCorrectKeyBoardNavigation_(new_i
tem)'
# function please?
# seems like I need to change state of the record (like in
ListCtrl(index, wx.LIST_STATE_FOCUSED | wx.LIST_STATE_SELECTED) but how?
my stats:
winXP, python 2.4.3, wxPython 2.8.4.2
···
---
igor@tyumbit.ru