Quantcast

Catching key events from a panel (and follow-up to stacked panels)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Catching key events from a panel (and follow-up to stacked panels)

Aaron J. M.
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.




stackpanel.py (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Catching key events from a panel (and follow-up to stacked panels)

Armando Serrano Lombillo
I haven't seen your code, but I've had similar problems recently which
I fixed by binding the EVT_KEY_DOWN in the App object. See this post
by Robin for a better explanation:
http://article.gmane.org/gmane.comp.python.wxpython/50485

Armando

On Feb 1, 2008 10:35 PM, Aaron MacDonald <[hidden email]> wrote:

> 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.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

yahody
In reply to this post by Aaron J. M.
Aaron,

> -----Original Message-----
> From: Aaron MacDonald [mailto:[hidden email]]
> Sent: Friday, February 01, 2008 3:36 PM
> To: [hidden email]
> 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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RE: Catching key events from a panel (and follow-up to stacked panels)

Aaron J. M.
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:[hidden email]]
>> Sent: Friday, February 01, 2008 3:36 PM
>> To: [hidden email]
>> 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: [hidden email]
> For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RE: Catching key events from a panel (and follow-up to stacked panels)

RobinLRandall@gmail.com
The  wx.EVT_CHAR worked for me. THANKS A LOT!
RR
Loading...