Hi, Here are some thoughts:
From the Python Library Reference: "If the subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread." You'll have to do that for your GuiScript class. You can't just stop a thread, you can only wait for it to finish using join(). Or you can set its deamon flag, so it will exit when no non-daemon threads are left. Is there any reason for starting the GUI code in a separate thread? You could just leave it in the main thread. For some general notes on this topic this might be helpful: http://wiki.wxpython.org/LongRunningTasks Cheers, Thomas Pani Varsha Purohit wrote: > Hello, > i have a gui program in wxpython where i am spawning two threads. > one for the mainloop of gui and other for some background tasks. I have > to stop the background running thread once its work is done. I am trying > to use the join method but it is giving me an error saying threads > cannot be joined as the thread has just been created... whereas at that > point the thread is done with its job. So i am confused whether i am > putting it correctly or not. also, is there any method called stop() to > stop the threads....Also, i want to see if the thread is alive or not.. > but i donno where should i put the isAlive() method associated with the > thread.. i tried putting it in the code where thread does execution but > apparently it is not the correct place......... > > Here is the code... > > class GuiScript(threading.Thread): > def __init__(self): > self.run() > def run(self): > app = wx.PySimpleApp() > MainWindow().Show() > app.MainLoop() > > class RunScript(threading.Thread): > def run(self): > imFile=test() > > and when the stop button is pressed the two threads should stop > executing... so i have written code like this... > > def OnCloseWindow(self,event): > GuiScript().Stop() > RunScript().Stop() > self.Destroy() > > but seems stop() method is not existing... can anybody guide me plzzzz > > thanks, > > > -- > Varsha Purohit, > Graduate Student > > > ------------------------------------------------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor