Why a key *and* an index for managing list controls

Hi All,

I'm trying to understand the code below. I've read quite some on listctrl's
and checked the API's but part is still unclear. I don't understand why
there's a key and an index. There seems to be some sort of mapping, but
either a key or an index itself should be enough to uniquely identify an
item.

The print statement in de loop, i(index), k(key), d(data), gave me this output
and it actually support my confusion .. :slight_smile:

i: 0 k: 1 d: ('80', 'A web server')
i: 1 k: 2 d: ('443', 'Secure web server')
i: 2 k: 3 d: ('9022', 'Obscure SSH')
i: 2 k: 4 d: ('1024', 'something')

The code:

        dstportsdata = {
        1 : ('80', 'A web server'),
        2 : ('443', 'Secure web server'),
        3 : ('9022', 'Obscure SSH'),
        4 : ('1024', 'something')
        }
        items = dstportsdata.items()
        for key, data in items:
            index = self.listdstports.InsertStringItem(sys.maxint, data[0])
            print 'i:', index, 'k:', key , ' d:', data
            self.listdstports.SetStringItem(index, 0, data[0])
            self.listdstports.SetStringItem(index, 1, data[1])
            self.listdstports.SetItemData(index, key)

Thanx a lot for any explanation or links.

Kind regards,

Gerard.

···

--
$Grtz =~ Gerard;
~
:wq!