首页 > 自定义事件在绑定时发生AssertionError

自定义事件在绑定时发生AssertionError

由于需要在不同类间传递数据,因此设计自定义事件,继承于wx.PyCommandEvent,定义如下:

class GenListEvent(wx.PyCommandEvent):
    def __init__(self, evtType, _id):
        wx.PyCommandEvent.__init__(self, evtType, _id)
        self.__list = []

    def setList(self, _list):
        self.__list = _list

    def getList(self):
        return self.__list

GEN_LIST_EVENT = wx.NewEventType()
GEN_LIST_EVENT_binder = wx.PyEventBinder(GEN_LIST_EVENT)

派发时,代码如下:

    evt = GenListEvent(GEN_LIST_EVENT, self.GetId())
    evt.setList(self.parent_index)
    self.GetEventHandler().ProcessEvent(evt)

在主View中绑定就发生断言错误了:

self.Bind(GEN_LIST_EVENT, self.__update_table_widthlist, self.__chooseList)

网上关于这类资料都很有限啊,求指导!

【热门文章】
【热门文章】