The Great 'Tian' uttered these words on 5/2/2005 2:00 PM:
> I have made a program in wxpython, but how could i exit the program? I
> am using wxFrame for my window, what is the function to close the
> program?
> 
> Thanks!!
> 

Tian,

See below:

--- CloseDemo.pyw ----

import wx

class MainFrame(wx.Frame):
        def __init__(self, parent, id, title, size, pos,\
        style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE):
                wx.Frame.__init__(self, parent, id, title, size, pos, style)
                # Bind close event here
                self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
                self.Show(True)
        
        #OnCloseWindow is executed when EVT_CLOSE is received

        def OnCloseWindow(self, evt):
                print 'OnCloseWindow() called'
                #Do other clean up action
                #and destroy frame
                self.Destroy()

app = wx.PySimpleApp()
frame = MainFrame(None, -1, "Test Close Event", (-1,-1), (-1,-1))
app.MainLoop()          

----------------------

Hope that helped.

Thanks,
-Kartic
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to