Trouble with wxListCtrl

Lukasz Pankowski lupan at
Mon Sep 22 21:34:41 CEST 2003

pkbf-tspx at (chauhan) writes:

> I am also having problem with statement
> self.list.GetItemText(self.currentItem). The statement
> self.currentItem gives the current selected item position on listctrl
> this statement works fine in wxPanel (demo example wxlistctrl in
> wxPython) and not with
> wxFrame which I am using now as I want menubar in my application. Can
> some body tell me how to get the current selected items position in
> wxListCtrl with wxFrame? Same kind of problem with wxPoint(self.x,
> self.y) but I can use wxGetMousePosition().

Hi, wxPanel or wxFrame has nothing to do with self.currentItem, this
attribute is set to 0 in TestListCtrlPanel.PopulateList in mentioned
example, they register a handler for item selection

        EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)

and in this hanler they set it to currently selected item:

   def OnItemSelected(self, event):
        ##print event.GetItem().GetTextColour()
        self.currentItem = event.m_itemIndex
        # [...]

This method tracks user selection, the other way is to find the
selected item when you need it:

    currentItem = self.list.GetNextItem(

this finds first selected item (first after -1).


=*= Lukasz Pankowski =*=

More information about the Python-list mailing list