List items onclick?

Okay so in my xml file ive definedmy grouplist as id 50
Ive generated a list through python but how do i define the onclick or onfocus for each item?
Do i define the ids of each item in the xml somehow? Or do it through python?