Re: Re: process an event without a window
kg*2 <[email protected]> Wed, 28 Feb 2018 09:17:59 -0800 (PST)
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
I did consider that, but I need the thread to run even if the __init__ raises an error.. I could wrap the window instantiation in a try/finally and still call the thread, but it leaves me with the same problem of not having a window to post the event to. I wasn't aware that you could bind to the wx.App so I'll try that and see how it works. On Tuesday, February 27, 2018 at 11:56:09 AM UTC-8, Nicolas Pinault wrote: > > 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] <javascript:>. > 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.