Problem with deselect event on a wx.listCtrl

Hi all !

(Im french, so sorry for my english !)

I've a problem with all the wx.listCtrl of my software : all works EXCEPT the
event wx.EVT_LIST_ITEM_DESELECTED !!! As you can see here, I use the listCtrl
which is in the wxPython demo :

class ListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin,
listmix.ColumnSorterMixin):
    def __init__(self, parent):
        wx.ListCtrl.__init__( self, parent, -1,
style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_SINGLE_SEL|wx.LC_HRULES|wx.LC_VRULES)
        
        # imageList here...
        
        # fill the ListCtrl here
        self.fill()

    def fill(self):
        
        # Récupération des données dans la base de données
        self.ImportValues()
        
        # Création des colonnes
        self.nbreColonnes = 3
        self.InsertColumn(0, u" ID")
        self.SetColumnWidth(0, 0)
        self.InsertColumn(1, u"Nom de la situation sociale")
        self.SetColumnWidth(1, 220)
        self.InsertColumn(2, u"Nb titulaires")
        self.SetColumnWidth(2, 80)

        #These two should probably be passed to init more cleanly
        #setting the numbers of items = number of elements in the dictionary
        self.itemDataMap = self.donnees
        self.itemIndexMap = self.donnees.keys()
        self.SetItemCount(self.nbreLignes)
        
        #mixins
        listmix.ListCtrlAutoWidthMixin.__init__(self)
        listmix.ColumnSorterMixin.__init__(self, self.nbreColonnes)

        #sort by genre (column 1), A->Z ascending order (1)
        self.SortListItems(1, 1)

        #events
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected)
        self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)
        #self.Bind(wx.EVT_SIZE, self.OnSize)

    def OnItemDeselected(self, evt):
        # >>>>>>>>>>
        print "This message never appears !!!!!!!!!!!!!"
        # <<<<<<<<<<
        
    def ImportValues(self):
        ........

    def MAJListeCtrl(self):
        self.ClearAll()
        self.Remplissage()
        self.resizeLastColumn(0)
        listmix.ColumnSorterMixin.__init__(self, self.nbreColonnes)

    def listeEnDict(self, liste):
        dictio = {}
        x = 1
        for ligne in liste:
            index = x # Donne un entier comme clé
            dictio[index] = ligne
            x += 1
        return dictio
        
    def getColumnText(self, index, col):
        item = self.GetItem(index, col)
        return item.GetText()

    def OnGetItemText(self, item, col):
        index=self.itemIndexMap[item]
        valeur = unicode(self.itemDataMap[index][col])
        return valeur

    def OnGetItemImage(self, item):
        return -1

    def OnGetItemAttr(self, item):
        if item % 2 == 1:
            return self.attr1
        else:
            return None

    def SortItems(self,sorter=cmp):
        items = list(self.itemDataMap.keys())
        items.sort(sorter)
        self.itemIndexMap = items
        # redraw the list
        self.Refresh()

    # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
    def GetListCtrl(self):
        return self

    # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
    def GetSortImages(self):
        return (self.imgTriAz, self.imgTriZa)

(I've the last version of wxPython and Python 2.5. System is windows Vista.)

If you found an idea... Thx for your help !!!

Ivan

Ivan wrote:

Hi all !

(Im french, so sorry for my english !)

I've a problem with all the wx.listCtrl of my software : all works EXCEPT the
event wx.EVT_LIST_ITEM_DESELECTED !!! As you can see here, I use the listCtrl
which is in the wxPython demo :

Does the ListCtrl sample in the demo also not send the EVT_LIST_ITEM_DESELECTED event? If it does then compare your code with the sample and see what you've done differently. If it also doesn't send the event then I expect that there is a problem due to some difference with the Vista version of the native widget. Please create a bug report about it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!