sending all key events to wx.panel?

K

KvS

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
 
S

Steve Holden

KvS said:
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
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
 
K

KvS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,588
Members
45,093
Latest member
Vinaykumarnevatia00

Latest Threads

Top