| 
      
      
      From: John L. <jla...@gm...> - 2006-12-25 04:38:27
      
     | 
| On 12/24/06, J=E9r=F4me VUARAND <jer...@gm...> wrote:
> 2006/12/24, John Labenski <jla...@gm...>:
> > On 12/24/06, J=E9r=F4me VUARAND <jer...@gm...> wrote:
> > > 2006/12/24, John Labenski <jla...@gm...>:
> > > > What you're suggesting is not normal, it's better to have the syste=
m's
> > > > native mainloop control program flow rather than implementing your =
own
> > > > which will most likely be far less efficient. In any case you shoul=
d
> > > > be able to do it using wxApp::Pending and wxApp::Dispatch.
> > >
> > > wxApp::Pending+wxApp::Dispatch seems to be exactly what I need.
> >
> > You may still want to consider using wxEVT_IDLE though since I think
> > that's what is typically suggested on the C++ wxusers mailing list for
> > doing pseudo-threading like this.
>
> I've tried Pending+Dispatch but that don't seems to work.
> wx.wxGetApp():Pending() never returns true.
>
> The code is :
> wx =3D require("wx")
> dofile(...)
> local use_custom_loop =3D true
> if use_custom_loop then
>     while true do
          while wx.wxGetApp():Pending() do
>             wx.wxGetApp():Dispatch()
>         end
           wx.wxMilliSleep(10) -- adjust as necessary
           wx.wxGetApp():ProcessIdle()
>     end
> else
>     wx.wxGetApp():MainLoop()
> end
>
> The command line is :
> lua bootstrap.lua minimal.wx.lua
>
> Everything works ok if I set my use_custom_loop to false. I'll have a
> look at the internals of MainLoop to see what may be missing. And I
> still need to try the idle event model, though I don't think that will
> match my timing requirement.
I can't test the changes above right now, but take a look at
wxPython's samples/mainloop/mainloop.py program and it's wxApp's
MainLoop function. Hopefully the only problem is that you need to
completely flush the events with the "while wx.wxGetApp():Pending()"
loop and give the event handler a little kick with
wx.wxGetApp():ProcessIdle() every once in a while.
see here and the posts before and after it.
http://lists.wxwidgets.org/archive/wxPython-users/msg07355.html
Regards,
    John Labenski
 |