我知道如何使用 wxpython GridCellChoiceEditor 将网格单元格更改为组合框,但不知道如何绑定这个组合框

I knew how to change a grid cell to a combobox by using wxpython GridCellChoiceEditor,but don't know how to bind for this combobox

这是我的代码的一部分。

class AboutRelatedDialog(wx.Dialog):

def __init__(self,parent,list1,list2,list3):

    wx.Dialog.__init__(self,parent,-1)

    RelatedGrid = gridlib.Grid(self)

    RelatedGrid.CreateGrid(sum(list2) + 1,5)
    RelatedGrid.SetColLabelSize(1)
    RelatedGrid.SetRowLabelSize(1)

    RelatedGrid.SetCellSize(0,0,1,2)
    RelatedGrid.SetCellAlignment(0,0,wx.ALIGN_CENTRE,wx.ALIGN_CENTRE)
    RelatedGrid.SetCellValue(0,0,'label')
    RelatedGrid.SetCellAlignment(0,2,wx.ALIGN_CENTRE,wx.ALIGN_CENTRE)
    RelatedGrid.SetCellValue(0,2,'datasource')
    RelatedGrid.SetCellAlignment(0,3,wx.ALIGN_CENTRE,wx.ALIGN_CENTRE)
    RelatedGrid.SetCellValue(0,3,'data')
    RelatedGrid.SetCellAlignment(0,4,wx.ALIGN_CENTRE,wx.ALIGN_CENTRE)
    RelatedGrid.SetCellValue(0,4,'comment')

    templist1 = ms.ExecQuery('SELECT RepGroup FROM RepGroup')
    templist2 = []
    for i in templist1:
        j = i[0]
        templist2.append(j)

    for index in range(len(list3)):
        RelatedGrid.SetCellAlignment(index + 1,1,wx.ALIGN_CENTRE,wx.ALIGN_CENTRE)
        RelatedGrid.SetCellValue(index + 1,1,list3[index])
    for i in range(sum(list2) + 1):
        dbsource = gridlib.GridCellChoiceEditor(templist2)
        RelatedGrid.SetCellEditor(i,2,dbsource)
        #RelatedGrid.Bind(wx.EVT_CHOICE,self.EvtChoice,dbsource)

def EvtChoice(self,event):
    print 1

而且我的代码不起作用,因为我不知道如何为这些组合框绑定事件。 当我选择一个数据源时,我想创建另一个组合框来显示从另一个单元格中的 RepGroup table 获得的数据。 所以我必须知道当我选择数据源时如何获取事件。

您不能(轻松地)绑定到 wxGrid 编辑器控件生成的事件,但您可以处理 EVT_GRID_CELL_CHANGED 网格本身在其中一个单元格的值发生变化时生成的事件.