我知道如何使用wxpythongridcellcooiceeditor将网格单元格更改为组合框,但不知道如何绑定此组合框

2024-05-18 08:18:13 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我代码的一部分。你知道吗

关于LatedDialog的类(wx.对话框)地址:

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表中获取的数据。 所以我必须知道如何在选择数据源时获取事件。你知道吗


Tags: inselfforindexdbsourcewxalignlist2
1条回答
网友
1楼 · 发布于 2024-05-18 08:18:13

您不能(轻松地)绑定到由wxGrid编辑器控件生成的事件,但是可以在网格的某个单元格的值发生更改时处理网格本身生成的EVT_GRID_CELL_CHANGED事件。你知道吗

相关问题 更多 >