Got it! I keep it as it is, and simply use the SetClientData() to give each Choice widget its place in the list:
def addAction(self, action):
# set the Choice in the cell
index = self.list.InsertStringItem(sys.maxint, '')
self.list.SetStringItem(index, self.columns['#'], str(index))
self.list.SetStringItem(index, self.columns['Action'], '')
self.list.SetStringItem(index, self.columns['Parameters'], '')
item = self.list.GetItem(index, self.columns['Action'])
choice = wx.Choice(self.list, -1, name=action.name,
choices=[availableAction.name for availableAction in self.availableActions])
choice.SetClientData(0, index)
choice.Bind(wx.EVT_CHOICE, self.onActionChange)
item.SetWindow(choice, expand=True)
self.list.SetItem(item)
# set the third column's widgets
self.setItemParameters(index, action)
def onActionChange(self, event):
action = copy.deepcopy(self.availableActionsDict[event.GetString()])
self.setItemParameters(event.GetEventObject().GetClientData(0), action)
I do need to update this every time the index is changed (like when an item is deleted from the middle of the list), but I can live with that.
Any other solutions will be appreciated