Re: AUI error: any pushed event handlers must have been removed

Christian K <[email protected]>
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
I had the same problem with 4.0.X versions. The solution is the following 
(quoting an old mail from Robin):

---

The assertion happens because the C++ wxAuiManager::SetManagedWindow does 
this:


m_frame->PushEventHandler(this);

but there is no corresponding PopEventHandler in the AUI code.

You can probably avoid the assertion by adding a EVT_CLOSE handler for the 
Frame passed to SetManagedWindow that does something like this:


self.PopEventHandler(True)
event.Skip() 


If something besides a Frame is the managed window then you’ll need to 
adapt to that configuration.
---

El domingo, 19 de abril de 2020, 19:21:18 (UTC-3), Al Goor escribió:
>
> I'm trying to work with AUI and keep getting the following error...
>
> wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" 
> failed at 
> /usr/local/miniconda/conda-bld/wxpython_1585592756259/work/ext/wxWidgets/src/common/wincmn.cpp(478) 
>
> in ~wxWindowBase(): any pushed event handlers must have been removed
>
> I've reduced my code down to a simple program that reproduces the error 
> (below).  Please note that the "MyFrame" definition is auto-generated by 
> wxFormBuilder, so I'm only supposed to modify that through subclasses.
>
> I've found references to this error on the internet, but none of the 
> solutions seem to match my case.
>
> Where am I going wrong?
>
> Thanks,
> Eric
>
> import wx
> import wx.xrc
> import wx.aui
>
>
> # Code for the frame was auto-generated by wxFormBuilder
>
> class MyFrame1(wx.Frame):
>
>     def __init__(self, parent):
>         wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString
> , pos=wx.DefaultPosition,
>                           size=wx.Size(870, 700), style=wx.DEFAULT_FRAME_STYLE 
> | wx.TAB_TRAVERSAL)
>
>         self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
>         self.m_mgr = wx.aui.AuiManager()
>         self.m_mgr.SetManagedWindow(self)
>         self.m_mgr.SetFlags(wx.aui.AUI_MGR_DEFAULT)
>
>         self.m_mgr.Update()
>         self.Centre(wx.BOTH)
>
>     def __del__(self):
>         self.m_mgr.UnInit()
>
>
> class MyApp(wx.App):
>
>     def OnInit(self):
>         self.frame = MyFrame1(None)
>         self.SetTopWindow(self.frame)
>         self.frame.Show(True)
>         return True
>
> # 
> -------------------------------------------------------------------------------
>
> def main():
>     app = MyApp(False)
>     app.MainLoop()
>
> # 
> -------------------------------------------------------------------------------
>
> if __name__ == "__main__":
>     main()
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/0e29f0db-7d56-41fa-b400-b09019f08698%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.