How close program in the wxPython?

T

Tian

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!!
 
F

Fabio Pliger

Tian said:
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!!

Wich version of wx? You cannot exit the program clicking "x" in the top
right of the win?
TO exit you can also bind the EVT_CLOSE event.....

F.P.
 
K

Kartic

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
 
T

Tian

I know how to capture window close event, but what i want to do is to
close window using commands. now i am simply using "sys.exit()" to
close the whole program. but it seems that window close events will are
be generated in this case. is there any function in wxpython that i can
use to close application window, yet generate the windows close event?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,237
Messages
2,571,190
Members
47,827
Latest member
wyton

Latest Threads

Top