[wxPython-users] Print framework on separate thread
Andrea Gavana
andrea.gavana at gmail.com
Thu May 3 04:25:25 PDT 2007
Hi Luca,
On 5/3/07, Luca Tavoletti wrote:
> It's possible to use the wx print framework inside a secondary thread?
The short answer is: no.
> My main frame launch a thread that run a long task and at the end send
> a print but
> when:
>
> class MyPrintout(wx.Printout):
> ...
> def OnPrintPage(self, page):
> dc = self.GetDC() <<<<<<<<<<<<<<
> ...
>
> I've this error:
> ....
> wx._core.PyAssertionError: C++ assertion "wxThread::IsMain()" failed
> at ..\..\src\msw\evtloop.cpp(244) in wxEventLoop::Dispatch(): only the
> main thread can process Windows messages
You can't generally call wx methods inside threads that are *not* the
main GUI thread.
> Is there any workaround to do this without use the post-event model?
Is using:
wx.CallAfter(WhateverMethodYouWant)
considered as post-event method? Why are you so concerned about
posting events? However, the simplest and safest approach is to use
wx.CallAfter from your secondary thread to call the main GUI thread
print methods.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
More information about the wxpython-users
mailing list