问题描述
有谁知道我如何修复以下错误:
self.vbSizers[turnNum].Remove(self.locations[turnNum])
builtins.TypeError: Sizer.Remove(): 参数不匹配任何重载调用:
重载 1:参数 1 具有意外类型“TextPanel”
重载 2:参数 1 具有意外类型“TextPanel”
“ADD”命令有效:
self.vbSizers[turnNum].Add(self.locations[turnNum],1,wx.EXPAND|wx.CENTRE)
那么为什么“删除”命令不起作用?这是源代码的链接:
https://github.com/horald/londonlaw/blob/master/londonlaw/guiclient/HistoryWindow.py 在第 104 行
非常感谢。
解决方法
BoxSizer 上的 Remove
函数需要一个索引作为输入。
Remove(...)
Remove(sizer) -> bool
Remove(index) -> bool
Removes a sizer child from the sizer and destroys it.
,
谢谢,但我如何找到索引?
我已经按照如下方式更改了源代码,但是当我尝试删除它时,出现了一个新错误。
if self.vbSizers[turnNum].IsEmpty() == False:
print(self.vbSizers[turnNum].GetItemCount())
self.vbSizers[turnNum].Remove(self.vbSizers[turnNum].GetItemCount())
wx._core.wxAssertionError: C++ assertion "index >= 0 && (size_t)index < m_children.GetCount()" failed at ../src/common/sizer.cpp(709) in Remove(): Remove index is out of range