[wxPython] Need help on wxOGL

Hi, I'm looking for a help.
I was playing with wxOGL sample code. I copied several lines into my test
code and it worked, but when the test script quit, I got the memory leak
error message.
My rough guess from wxOGL.py example code is that I should do something when
the window is closed.
I might be able to use the following code (from wxOGL.py), but I have no
idea what they are.
I already tied to add the following code at the end of my code, but it
didn't work.
Is there anybody to explain them?

···

###########################
class __Cleanup:
    cleanup = wxOGLCleanUp
    def __del__(self):
        self.cleanup()

# when this module gets cleaned up then wxOGLCleanUp() will get called
__cu = __Cleanup()

#############################

I also tried to manually clearn up wxOGL object by adding the Destroy()
method into my wxShapeCanvas object as follows:
    def Destroy( self ):
        wxOGLCleanUp()
        wxShapeCanvas.Destroy()

But neither worked.

Thanks in advance.

YJ

I found the answer in the sample code. I must have been blind yesterday. I
don't understand why I didn't find it.
In order to clean wxOGL object, the __del__ method should be implemented as
follows:
    def __del__( self ):
        for shape in self.diagram.GetShapeList():
            if shape.GetParent() == None:
                shape.SetCanvas(None)
                shape.Destroy()
        self.diagram.Destroy()

Sorry for messing up the mailing list. :frowning:

···

----- Original Message -----
From: "Young-Jin Lee" <ylee12@uiuc.edu>
To: <wxpython-users@lists.wxwindows.org>
Sent: Monday, January 21, 2002 7:43 PM
Subject: [wxPython] Need help on wxOGL

Hi, I'm looking for a help.
I was playing with wxOGL sample code. I copied several lines into my test
code and it worked, but when the test script quit, I got the memory leak
error message.
My rough guess from wxOGL.py example code is that I should do something

when

the window is closed.
I might be able to use the following code (from wxOGL.py), but I have no
idea what they are.
I already tied to add the following code at the end of my code, but it
didn't work.
Is there anybody to explain them?
###########################
class __Cleanup:
    cleanup = wxOGLCleanUp
    def __del__(self):
        self.cleanup()

# when this module gets cleaned up then wxOGLCleanUp() will get called
__cu = __Cleanup()

#############################

I also tried to manually clearn up wxOGL object by adding the Destroy()
method into my wxShapeCanvas object as follows:
    def Destroy( self ):
        wxOGLCleanUp()
        wxShapeCanvas.Destroy()

But neither worked.

Thanks in advance.

YJ

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users