[wxPython-users] RE: Catching key events from a panel (and follow-up to stacked panels)

Aaron MacDonald ajmacd at ns.sympatico.ca
Mon Feb 4 08:11:05 PST 2008


I'm on a Mac OS X 10.5, and I'm using wxPython v2.8.7.1 (I think) for  
Python v2.5.

Also, this problem occurs when I have sub-panels inside these panels  
that are in my frame.

On 4-Feb-08, at 11:32 AM, Mike Driscoll wrote:

> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org




More information about the wxpython-users mailing list