choice_editor 其實有一個内部的編号,每一次調用choice editor 即setcelleditor的時候,這個值都需要手動加一 。
self.grid.CreateGrid(row_number, self.col_num )
# self.grid add select list
self.grid_choice_list = ['test1', 'test2']
#choice_editor = wx.grid.GridCellChoiceEditor(self.grid_choice_list,allowOthers=True)
choice_editor = wx.grid.GridCellChoiceEditor(self.grid_choice_list)
for col in range(self.col_num ):
self.grid.SetColLabelValue(col,rowLabels[col])
self.grid.SetColSize(col, 125)
for row in range(row_number):
for col in range(self.col_num ):
#self.grid.SetCellBackgroundColour(row, col, "light grey")
self.grid.SetCellBackgroundColour(row, col, "white")
if col==3:
self.grid.SetCellEditor(row,col,choice_editor)
choice_editor.IncRef() # 手動加1
print(choice_editor.GetRefCount())# 看看有無變化
self.grid.SetCellValue(row,col,self.grid_choice_list[0])
#self.grid.SetReadOnly(row, col)