On 8/20/07, <b class="gmail_sendername">[david]</b> <<a href="mailto:david@nospam.spam">david@nospam.spam</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
What am I doing wrong?<br>I'm trying to capture stdErr in a multi-threaded program.</blockquote><div><br>You can't reliably access the GUI anywhere except in the main thread; you're printing to stderr from the worker thread, and thus its writing to the GUI control, and that action is occuring within the worker thread. Sometimes it'll work. Eventually it'll always fail.
<br><br>Try adjusting the write method of RedirectText to:<br><br>    def write(self,string):<br>         wx.CallAfter(self.out.WriteText, string)<br><br>"wx.CallAfter" is a convienence function to call from a worker thread "into" the GUI thread and execute the specified method with the given options. It makes modifying the GUI very easy.
<br><br>--S<br></div></div>