On Fri, 15 Sep 2006 12:47:30 -0700, abcd wrote: > I have a python script which creates a wx.App, which creates a wx.Frame > (which has a wx.Timer). > > looks sorta like this: > > class MyProgram: > def __init__(self): > self.app = MyApp(0) > self.app.MainLoop() > > class MyApp(wx.App): > def OnInit(self): > self.myframe= MyFrame() > self.myframe.Show(True) > self.SetTopWindow(self.myframe) > return True > > class MyFrame(wx.Frame): > def __init__(self): > # do some other stuff here > > # setup the timer > self.timer = wx.Timer(self) > self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) > self.timer.Start(100) > > def killTimer(self): > self.Unbind(wx.EVT_TIMER) > self.timer.Stop() > self.timer = None > > > ....that's the jist of it. > > Anyhow, so I startup python and import my script, which loads up the > wx.App, frame and all. > > foo = MyProgram() > > > Then I close the frame. when the frame is closed it calls killTimer. > This method gets called and no exceptions occur. > > Then...I create a new instance of the app and try to load the frame > again. > > foo = MyProgram() > > ...and I am getting this error: > > "timer can only be started from the main thread" > > how can I fix this?? > > FYI, my script is being started by a new thread each time, so > ultimately we have.... > > def startProgram(): > foo = MyProgram() > > threading.Thread(target=startProgram).start() > > > Thanks in advance.
You must not access wx from more than one thread. Read their wiki about this and about the appropriate workaround. Morpheus -- http://mail.python.org/mailman/listinfo/python-list