Sizer.Remove():参数与任何重载调用不匹配

2024-10-04 03:28:26 发布

您现在位置:Python中文网/ 问答频道 /正文

是否有人知道如何修复以下错误:

self.vbSizers[turnNum].Remove(self.locations[turnNum])

builtins.TypeError:Sizer.Remove():参数与任何重载调用不匹配:
重载1:参数1具有意外的类型“TextPanel”
重载2:参数1具有意外类型“TextPanel”

“添加”命令的作用是:

self.vbSizers[turnNum].Add(self.locations[turnNum], 1, wx.EXPAND|wx.CENTRE)

那么为什么“删除”命令不起作用呢?以下是源代码的链接:

https://github.com/horald/londonlaw/blob/master/londonlaw/guiclient/HistoryWindow.py 第104行

多谢各位


Tags: 命令self类型参数错误removewxlocations
2条回答

BoxSizer上的Remove函数需要一个索引作为输入

Remove(...)
    Remove(sizer) -> bool
    Remove(index) -> bool
    
    Removes a sizer child from the sizer and destroys it.

谢谢,但是我如何找到索引呢

我对源代码做了如下更改,但是当我试图删除它时,出现了一个新的错误

&13; 第13部分,;
  if self.vbSizers[turnNum].IsEmpty() == False:
     print(self.vbSizers[turnNum].GetItemCount())
     self.vbSizers[turnNum].Remove(self.vbSizers[turnNum].GetItemCount())
和#13;
和#13;

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

相关问题 更多 >