I am writing a wxListCtrl subclass with helper methods for unit testing GUI
that use list controls.
Right now, I need methods to programmatically:
1. set the selected item in the list
2. query the list for its selected item
I have gotten 2. to work, but 1. doesn't. In the code below, when I invoke
DoSelectItem(), both SelectedItem() and DoSelectItem() print -1. Yet, when I
manually click on an item in the list, SelectedItem() prints the correct
item index.
What am I doing wrong?
Thx.
···
----------
class wxListCtrlWithHelpers(wxListCtrl):
def SelectedItem(self):
selected = self.GetNextItem(-1, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED)
print '-- SelectedItem: returning %s' % selected
return selected
def DoSelectItem(self, row, column):
self.SetItemState(row, column, wxLIST_STATE_SELECTED)
print '-- DoSelectedItem: after selecting row=%s, column=%s, selected
item is: %s' % \
(row, column, self.SelectedItem())
Alain Désilets, MASc
Agent de recherches/Research Officer
Institut de technologie de l'information du CNRC /
NRC Institute for Information Technology
alain.desilets@nrc-cnrc.gc.ca
Tél/Tel (613) 990-2813
Facsimile/télécopieur: (613) 952-7151
Conseil national de recherches Canada, M50, 1200 chemin Montréal,
Ottawa (Ontario) K1A 0R6
National Research Council Canada, M50, 1200 Montreal Rd., Ottawa, ON
K1A 0R6
Gouvernement du Canada | Government of Canada