sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
KvS's Avatar

sending all key events to wx.panel?


Question posted by: KvS (Guest) on November 25th, 2005 01:25 AM
Hi all,

I have a wxPython GUI consisting of a wxWindow -> wxPanel -> set of
widgets. I need to catch pressed keys no matter which widget has focus,
so I've attached an event handler to the panel but I can't seem to find
a way to do some kind of collective "sending through" of the key event
from all the widgets on the panel to that handler in case the panel
doesn't have focus. Is there some way to do this?

Thanks in advance!

- Kees

2 Answers Posted
Steve Holden's Avatar
Guest - n/a Posts
#2: Re: sending all key events to wx.panel?

KvS wrote:[color=blue]
> Hi all,
>
> I have a wxPython GUI consisting of a wxWindow -> wxPanel -> set of
> widgets. I need to catch pressed keys no matter which widget has focus,
> so I've attached an event handler to the panel but I can't seem to find
> a way to do some kind of collective "sending through" of the key event
> from all the widgets on the panel to that handler in case the panel
> doesn't have focus. Is there some way to do this?
>
> Thanks in advance!
>
> - Kees
>[/color]
Why not just attach the event handler to the wxWindow containing the
panel? If the panel ignores keyboard events they'll just rise to the
containing window, won't they?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

KvS's Avatar
Guest - n/a Posts
#3: Re: sending all key events to wx.panel?

I've tried, by setting

self.Bind(wx.EVT_CHAR, self.handleKeybEv, self)

in the top level frame, but still this only works if the panel has
focus and not if e.g. a button on the panel has focus while a key is
pressed...

In the meantime I found this:

"In some cases, it might be desired by the programmer to get a certain
number of system events in a parent window, for example all key events
sent to, but not used by, the native controls in a dialog. In this
case, a special event handler will have to be written that will
override ProcessEvent() in order to pass all events (or any selection
of them) to the parent window."

in wxPython docupart on event handling. Anybody who has done something
like that before?

- Kees

 
Not the answer you were looking for? Post your question . . .
196,942 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,942 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors