简体   繁体   中英

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

this is a part of my code.

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

and my code doesn't work,because i don't know how to bind a event for these combobox. when i choose a datasource,i want to create another combobox to show the data that get from the RepGroup table in another cell. so i must know how to get the event when i choose a datasoure.

您不能(轻松地)绑定到由wxGrid编辑器控件生成的事件,但是,只要其中一个单元格的值发生更改,就可以处理由网格本身生成的EVT_GRID_CELL_CHANGED事件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM