无法在 wxPython 虚拟网格中添加列

can't add columns in wxPython virtual grid

我有一个带有非常大网格的 wxPython GUI。我正在使用与 wxPython 演示中的 GridHugeTable.py 示例类似的代码——即使用 PyGridTableBase 制作虚拟网格。

但是,当我尝试以交互方式向该网格添加列时,我 运行 遇到了麻烦。

调用 AppendCols(1) 导致此错误:

wx._core.PyAssertionError: C++ assertion "Assert failure" failed at /Users/vagrant/pisi-64bit/tmp/wxPython-3.0.2.0-3/work/wxPython-src-3.0.2.0/src/generic/grid.cpp(1129) in AppendCols(): 
Called grid table class function AppendCols but your derived table class does not override this function

但是如果我尝试在我的 table class 中覆盖 AppendCols,应用程序就会无限期地挂起并且永远不会解析。即使我的自定义 AppendCols 方法中实际上没有任何内容,它也会挂起...

class HugeTable(gridlib.PyGridTableBase):

    """                                                                                                             
    Table class for virtual grid                                                                                    
    """

    def __init__(self, log, num_rows, num_cols):
        gridlib.PyGridTableBase.__init__(self)

    def AppendCols(self, *args):
        pass

我已经能够成功覆盖其他方法(setValue、getValue、getColLabelValue 等),所以我不确定这里有什么不同。

更新:

一段时间后我又回到了这个问题。我不再得到 wx.__core.PyAssertionError。但是,我仍然无法使用我的自定义 AppendCols 方法。我不知道要在 AppendCols 中放入什么才能使新列实际上出现。

我不确定如何查看源代码 -- Python 文档的 none 似乎有我要找的东西,所以也许我需要深入挖掘wx 小部件?文档没有帮助:https://wiki.wxpython.org/wxPyGridTableBase

我需要的线索在 custom table 的演示代码中。

所以,这段代码有效(省略了我的自定义逻辑,只包含了基本内容):

 def AppendCols(self, *args):
     msg = gridlib.GridTableMessage(self,  # The table                                               
                           gridlib.GRIDTABLE_NOTIFY_COLS_APPENDED, # what we did to it              
                           1)                                       # how many                      
    self.GetView().ProcessTableMessage(msg)
    return True