Add IsMainThread and use it in the PyOnDemandOutputWindow class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72023 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-07-11 08:49:56 +00:00
parent dc1287e9ce
commit a1163deb78
2 changed files with 7 additions and 2 deletions

View File

@@ -419,6 +419,11 @@ def run():
])
module.addCppFunction('bool', 'IsMainThread', '()',
doc="Returns True if the current thread is what wx considers the GUI thread.",
body="return wxThread::IsMain();")
module.addInitializerCode("""\
wxPyPreInit(sipModuleDict);
""")

View File

@@ -270,12 +270,12 @@ def run():
""",
body="""\
if self.frame is None:
if not wx.Thread.IsMain():
if not wx.IsMainThread():
wx.CallAfter(self.CreateOutputWindow, text)
else:
self.CreateOutputWindow(text)
else:
if not wx.Thread.IsMain():
if not wx.IsMainThread():
wx.CallAfter(self.text.AppendText, text)
else:
self.text.AppendText(text)