- def write(self, str):
- if not wx.Thread_IsMain():
- # Aquire the GUI mutex before making GUI calls. Mutex is released
- # when locker is deleted at the end of this function.
- locker = wx.MutexGuiLocker()
-
- if not self.frame:
- self.frame = wx.Frame(self.parent, -1, self.title,
- style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
- self.text = wxTextCtrl(self.frame, -1, "",
- style = wx.TE_MULTILINE | wx.TE_READONLY)
- self.frame.SetSize((450, 300))
- self.frame.Show(True)
- EVT_CLOSE(self.frame, self.OnCloseWindow)
- self.text.AppendText(str)
+ def write(self, text):
+ """
+ Create the output window if needed and write the string to it.
+ If not called in the context of the gui thread then uses
+ CallAfter to do the work there.
+ """
+ if self.frame is None:
+ if not wx.Thread_IsMain():
+ wx.CallAfter(self.CreateOutputWindow, text)
+ else:
+ self.CreateOutputWindow(text)
+ else:
+ if not wx.Thread_IsMain():
+ wx.CallAfter(self.text.AppendText, text)
+ else:
+ self.text.AppendText(text)
+