How to fix "memory leak like" wxPyXmlSubclassFactory * ", no destructor" from wxPython / wxFormBuilder was detected?

I am trying to follow this tutorial to quickly make simple graphical interfaces using wxPython and wxFormBuilder.

Using wxFormBuilder, I created a super simple frame with one vertical layout, one text edit control and a button that only clears the value of the text control. WxFormBuilder generated 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 a silly simple frame.

simple frame

When I run this file in Python, the GUI clears the text that I type in the text control. When I click the close button, I see the following:

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

I tried the problem with Google, but found that Python is dynamic enough not to require destructors. I tried to add a function __del__, but I still have the same error message.

Ideas for getting rid of this error? I use:

  • Python 2.7.6
  • wxPython 3.0.0.0 for Python 2.7
  • wxFormBuilder 3.4.2
  • Windows 7 32-bit

Thank you so much in advance!

Here is the code I need if someone 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()
+4
source share
2 answers

(3.0.0). . . , .

+4

, , wxPython, , , :

http://trac.wxwidgets.org/changeset/75542

wxPython, 3.0.0 (Dec) , (Jan), , , , wxPython? , , . !

+3
source

Source: https://habr.com/ru/post/1532067/


All Articles