July 5th, 2004, 04:35 PM
I do not know anything about the ogg API, but I presume there is a function to stop the audio. So the problem is how to call this function when the user exits your program. There are basically two ways to do this in wxPython:
1) You can associate a function with the close event of the main Frame, using EVT_CLOSE.
2_ Alternatively you could override the OnExit method of the class you derive from wxApp, to do the cleanup when the application exits.
I think the first option is preferable. If you trap the close event then you must call the Frame's Destroy method to actually close the window.
Here is a simple example:
def __init__(self, parent=None, id=-1,
pos=wx.DefaultPosition, title='Close Me'):
wx.Frame.__init__(self, parent, id, title, pos)
def onClose(self, event):
'''called when the Frame is closed by whatever means'''
wx.MessageBox('Bye Bye', 'Closing')
self.frame = Frame()
app = App()
if __name__ == '__main__':
This will pop up a message box when the Frame is closed, either through clicking on the X or pressing Alt-F4 (on Windows).
Dave - The Developers' Coach