How do I Block Events in wxPython

Stephen Hansen apt.shansen at gmail.com
Thu Dec 10 11:16:15 EST 2009


On Thu, Dec 10, 2009 at 6:01 AM, Frank Millman <frank at chagford.com> wrote:

> > Another approach is to use wnd.CaptureMouse() on a particular control
> > which
> > doesn't really respond to anything. Just be sure to ReleaseMouse() later
> > and
> > follow the instructions in the docs about capturing that cancel-capture
> > event.
> >
>
> I like this. Unfortunately it does not block keyboard input. However, I
> have
> a keyboard event handler on virtually all my controls, so it should be easy
> to set a flag and tell it to ignore keystrokes while in a 'blocked' state.
>

Hm, that's a point.

Well if you have a legitimate case for pre-empting the event loop with these
periodic regular short blocking moments (it seems you may), I think what you
want to do is overwrite FilterEvent on your App object. You can then make
that flag something you set on the app, and while it's true, returning False
(or True, I really don't know the differenced between telling wx 'Ok, I
processed this event you can ignore it' and 'Ok, I'm not going to process
this event and neither should you'). Otherwise, return -1.

--S


> > HTH,
>
> It certainly does - thanks.
>
> Frank
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091210/267589a8/attachment-0001.html>


More information about the Python-list mailing list