Catching key events from a panel (and follow-up to stacked panels)
Mike Driscoll
mdriscoll at co.marshall.ia.us
Mon Feb 4 07:32:28 PST 2008
Aaron,
> -----Original Message-----
> From: Aaron MacDonald [mailto:ajmacd at ns.sympatico.ca]
> Sent: Friday, February 01, 2008 3:36 PM
> To: wxPython-users at lists.wxwidgets.org
> Subject: Catching key events from a panel (and follow-up to
> stacked panels)
>
> Hello,
>
> I want to capture key events somehow. My frame as a panel to
> which I try to bind to wx.EVT_KEY_DOWN, which hasn't been
> working. I later read that wx.EVT_KEY_DOWN aren't propagated
> and that the focus may probably in one of the
> controls/subpanels inside my main panel, event though I
> called SetFocus() on my main panel.
>
> While wx.EVT_KEY_DOWN doesn't work, wx.EVT_CHAR does.
> However, I am not clear what exactly is the difference
> between the two for when I just want to test key codes. Is
> this something I should worry about?
>
> Also, I think I've figured out my last question about frames
> with a group of panels with only one visible panel. I've
> implemented a subclass of frame where panels are added to it
> with a key, where I've attached a demonstration. The frame
> resizes itself to fit the maximum width and height of any panel.
>
> Cheers,
>
> Aaron M.
>
>
I'm confused. This works for me (mostly) on Windows XP with wxPython
2.8.7.1. I put a
print event.GetKeyCode()
in your event handlers (Switch) and they printed the key codes for me. I
use the EVT_KEY_DOWN event in my grid object to catch keypresses and they
work flawlessly. What OS and wxPython version are you using?
Mike
More information about the wxpython-users
mailing list