Re: Re: process an event without a window

Nicolas Pinault <[email protected]> Tue, 27 Feb 2018 20:55:59 +0100
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
Le 26/02/2018 à 23:25, kg*2 a écrit :
> I use a background thread to contact a server and then use PostEvent 
> to deliver the results to the main thread. This has created a race 
> condition where the server thread can sometimes (1 in a 100) return 
> before the main window has been created. I'm currently creating a 
> temporary wx.Frame and posting the event to that to work around the 
> issue, but I figured there was a better way to do it.
Why don't you launch your background thread from the main window 
__init_() method ? I do this in several of my projects at work without 
any issue.
>
> On Monday, February 26, 2018 at 10:56:35 AM UTC-8, Robin Dunn wrote:
>
>     On Friday, February 23, 2018 at 12:17:09 PM UTC-8, kg*2 wrote:
>
>         Is it possible to process a custom event before a window has
>         been created?
>
>
>     Maybe, it depends on how you need it to work.  There has to be an
>     object derived from wx.EvtHandler to bind the handler and to
>     receive the event, and unless the MainLoop is running you will
>     only be able to do immediate event processing, not holding the
>     event for processing later. For example, you could bind a handler
>     to the wx.App object, and then send it an event with
>     wx.GetApp().ProcessEvent(event), but with those limitations you
>     may as well just call the method directly.
>
>     -- 
>     Robin Dunn
>     Software Craftsman
>     http://wxPython.org
>
> -- 
> You received this message because you are subscribed to the Google 
> Groups "wxPython-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.