pythonwxpythonwxformbuilder

How do I fix a "memory leak of type 'wxPyXmlSubclassFactory *', no destructor found" error from wxPython/wxFormBuilder?


I'm trying to follow this tutorial to quickly make simple GUIs using wxPython and wxFormBuilder.

Using the wxFormBuilder, I created a super simple frame with one vertical layout, one edit text control and a button, which only clears the value of the text control. WxFormBuilder generated the Python code and I just added a few lines to clear the value of the text control when the button is clicked. Here is an image of the stupid simple frame.

simple frame

When I run this file in Python, the GUI does clear the text I type in the text control. When I click on the Frame's close button, I see this:

swig/python detected a memory leak of type 'wxPyXmlSubclassFactory *', no destructor found.

I tried Googling the issue but only found that Python is dynamic enough to not require destructors. I did try out adding the __del__ function, but I still got the same error message.

Ideas for getting rid of that error? I'm using:

Thank you so much in advance!

Here's the code I have if anyone needs it:

# -*- coding: utf-8 -*- 

###########################################################################
## Python code generated with wxFormBuilder (version Feb 26 2014)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################

import wx
import wx.xrc

###########################################################################
## Class MyFrame1
###########################################################################

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( 203,155 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )

        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )

        bSizer1 = wx.BoxSizer( wx.VERTICAL )

        self.edit = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer1.Add( self.edit, 1, wx.ALL|wx.EXPAND, 5 )

        self.clearButton = wx.Button( self, wx.ID_ANY, u"Clear", wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer1.Add( self.clearButton, 1, wx.ALL|wx.EXPAND, 5 )


        self.SetSizer( bSizer1 )
        self.Layout()

        self.Centre( wx.BOTH )

        # Connect Events
        self.clearButton.Bind( wx.EVT_BUTTON, self.clearFunc )

    def __del__( self ):
        pass


    # Virtual event handlers, overide them in your derived class
    def clearFunc( self, event ):
        event.Skip()

class SimpleFrame(MyFrame1):
    def __init__(self,parent):
        MyFrame1.__init__(self,parent)

    def clearFunc(self,event):
        self.edit.SetValue("")

app = wx.App(False)
frame = SimpleFrame(None)
frame.Show(True)
app.MainLoop()

Solution

  • I keep getting the same error with the latest version (3.0.0). No new version's been released since. No need to worry though. Expect to see a fix sometime soon.

    Take a look at the last post here