【发布时间】:2010-07-02 20:35:07
【问题描述】:
我创建了一个带有 wx.grid.PyGridTableBase 派生类的 wx.grid.Grid 来提供它的数据。我还想控制桌子上使用的编辑器。为此,我定义了以下方法
def GetAttr(self, row, col, kind):
attr = wx.grid.GridCellAttr()
if col == 0:
attr.SetEditor( wx.grid.GridCellChoiceEditor() )
return attr
但是,每当我尝试在网格中创建编辑器时,这都会导致分段错误。我确实尝试过事先创建编辑器并将其作为参数传递,但收到错误:
TypeError: in method 'GridCellAttr_SetEditor', expected argument 2 of type
'wxGridCellEditor *'
我怀疑第二个错误是由 GridCellAttr 取消所有权然后破坏我的编辑器引起的。
我也尝试过在 wx.grid.Grid 上使用 SetDefaultEditor 方法,这很有效,但自然不允许我使用特定于列的编辑策略。
查看崩溃程序的完整示例:http://pastebin.com/SEbhvaKf
【问题讨论】: