> Actually I am using wxPython for a GUI front-end. Thus, it is already > in a class. I am not sure how to apply your idea to a program that is > already running in an infinite event loop.
I don't know wxPython, but I was able to grab an example program and adapt it to do what I think you are asking for. Something like this: [code] #! /usr/bin/env python from wxPython import wx ID_EXIT = 101 ID_RST = 102 class MyFrame(wx.wxFrame): def __init__(self, parent, ID, title): wx.wxFrame.__init__(self, parent, ID, title, wx.wxDefaultPosition, wx.wxSize(200, 150)) self.CreateStatusBar() self.SetStatusText("This is the statusbar") menu = wx.wxMenu() menu.Append(ID_EXIT, "E&xit", "Terminate the program") menu.Append(ID_RST, "&Restart", "Restart the program") menuBar = wx.wxMenuBar() menuBar.Append(menu, "&File"); self.SetMenuBar(menuBar) wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit) wx.EVT_MENU(self, ID_RST, self.TimeToRestart) def TimeToQuit(self, e): self.Close(wx.true) def TimeToRestart(self, e): global restart restart = True self.TimeToQuit(e) class MyApp(wx.wxApp): def OnInit(self): global restart restart = False frame = MyFrame(wx.NULL, -1, "Hello from wxPython") frame.Show(wx.true) self.SetTopWindow(frame) return wx.true if __name__ == "__main__": MyApp(0).MainLoop() while restart: MyApp(0).MainLoop() [/code] -- http://mail.python.org/mailman/listinfo/python-list