The question in the comment below.
from wxPython.wx import *
ID_EXIT = 102
class MainPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1,
style=wxNO_FULL_REPAINT_ON_RESIZE)
Btn_Close = wxButton(self,ID_EXIT,"Close")
EVT_BUTTON(self, ID_EXIT, self.TimeToClose)
def TimeToClose(self, event):
# HowTO.Close() the program from here?
pass
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition)
self.panel_1 = MainPanel(self,-1)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Test")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
Robin
May 5, 2003, 6:39pm
2
Keijo Kleemola wrote:
The question in the comment below.
from wxPython.wx import *
ID_EXIT = 102
class MainPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1,
style=wxNO_FULL_REPAINT_ON_RESIZE)
Btn_Close = wxButton(self,ID_EXIT,"Close")
EVT_BUTTON(self, ID_EXIT, self.TimeToClose)
def TimeToClose(self, event):
# HowTO.Close() the program from here?
pass
wxGetTopLevelParent(self).Close()
That will close the top level parent of the panel, and since this is the only frame in this app the app will exit.
···
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition)
self.panel_1 = MainPanel(self,-1)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Test")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!