Getting data from threads to wxNoteBook

Hi,
I've got a dynamically populated wxNoteBook (which I have no problems
with) and in each of these pages there is a button to spawn a certain
process using something like this:

from threading import Thread

class run_it(Thread):
    def __init__(self,name,params):
        Thread.__init__(self)
        self.name = name
        self.params = params
        self.should_run = True

    def run(self):
        result = []
        if self.should_run:
            start_runner(self.name,self.params)
        return result

    def stopper(self):
        self.should_run = False

def start_runner(name,params):
    print "starting"
    #things will be done here and there will be alot of print
statements

Now my question is how do I get the print statements that are from
this separate thread/function back to the wxNoteBook's page (that has
a wxTextCtrl on it)? Is it a simple matter of std.out redirection? I
think there is more to this since it is a different python thread
altogether.
Thanks for any help

Hi,

Now my question is how do I get the print statements that are from
this separate thread/function back to the wxNoteBook's page (that has
a wxTextCtrl on it)? Is it a simple matter of std.out redirection? I
think there is more to this since it is a different python thread
altogether.

There are several ways to do it that may be better or worse suited
depending upon your application but here is one simple way is to just
pass a fuction to the thread and use CallAfter to call it to update
the TextCtrl with the text.

class MyThread(...):
   def __init__(..,...,..,notifyerFunction):
        self._notify = notiferFunction

   def run(...):
       ...
       wx.CallAfter(self._notify, someText)

class MyNotebookPage(...):
    def ThreadCallBack(self, someText):
        self._textCtrl.AppendText(someText)

def OnButton(....):
    thread = MyTread(...,...,..,mynotebook_instance.ThreadCallBack)
    thread.start()

Cody

···

On Tue, May 8, 2012 at 3:09 AM, Astan <astan.chee@rhubarbfizz.com> wrote: