1

我有以下用于关闭面板的功能:

def close_active_panel
  if (@active_panel and @active_panel.class <= Wx::Window)
    @sizer.detach(@active_panel)
    @sizer.remove(0) # 0 is index of first and only item, the active panel
    @active_panel.destroy_children
    @active_panel.destroy
  end
end

这在大多数情况下都有效,但偶尔(我似乎找不到发生这种情况的模式),它会引发以下异常:

ArgumentError
Wrong arguments for overloaded method 'wxSizer.Detach'. Possible C/C++ prototypes are: bool wxSizer.Detach(wxWindow *window) bool wxSizer.Detach(wxSizer *sizer) bool wxSizer.Detach(size_t index)

发生这种情况似乎很奇怪,因为它甚至应该到达 detach 方法的唯一方法是 active_panel 从 Wx::Window 类继承。

我在这里缺少某种继承技巧吗?我已经尝试输出活动面板的类及其父类,以确保它确实是从 Wx::Window 继承的,并且问题仍然存在。任何帮助将不胜感激。

4

0 回答 0