[wxPython] menus and accelerator keys on wxGTK

I'm debugging a wxPython app on Linux/wxGTK (wxPython 2.3.2.1 from rpm, Python 2.1, Mandrake 8.1) which I originally wrote and tested on Win32 (wxPython 2.3.2.1, Python 1.52, Win98SE).

I'm trying to get the Unix version to follow the same user-interface conventions for menus as the Windows version (standardization of Alt-key accelerators with underlined letters being one of the few points on which MSW beats Unix/Linux).

I've noticed a few pecularities about accelerator keys for menus and menu items:

1. Including an ampersand (&) in the menu name underlines the following letter and automatically creates an accelerator key, on Linux/GTK just as on Windows (Hooray!!). However, alt-f (for the file menu) gets intercepted by a wxTextCtrl (when it has the focus) and processed as the Emacs shortcut for previous-word. I've been able to override this by adding an explicit check for alt-f to my EVT_CHAR handler for the text control, and calling the_frame.wxProcessEvent instead of event.Skip() in that case. I'm just wondering if this is the right way to do this, or if there is a cleaner way to make the menu shortcuts take precedence over the text control ones.

2. I've also included hints for keyboard shortcuts following a tab in the menu item titles, following the windows convention (e.g. '&Undo\tCtrl+Z'). These have to be added to the accelerator table explicitly, even on Windows, and then they seem to work on either platform. However, in Linux/GTK, if I press a ctrl- or alt-modified key while one of the menus is open, the text of the menu hint for the current menu item changes to that key, and the original accelerator key stops working until I change the hint back. (The new key doesn't start working though). Is there any way to prevent this?

Thanks,
David

David C. Fox wrote:

I'm debugging a wxPython app on Linux/wxGTK (wxPython 2.3.2.1 from rpm, Python 2.1, Mandrake 8.1) which I originally wrote and tested on Win32 (wxPython 2.3.2.1, Python 1.52, Win98SE).

1. Including an ampersand (&) in the menu name underlines the following letter and automatically creates an accelerator key, on Linux/GTK just as on Windows (Hooray!!). However, alt-f (for the file menu) gets intercepted by a wxTextCtrl (when it has the focus) and processed as the Emacs shortcut for previous-word. I've been able to override this by adding an explicit check for alt-f to my EVT_CHAR handler for the text control, and calling the_frame.wxProcessEvent instead of event.Skip() in that case. I'm just wondering if this is the right way to do this, or if there is a cleaner way to make the menu shortcuts take precedence over the text control ones.

Followup:

I didn't test my workaround properly (the focus must not have been on the text control) - the_frame.ProcessEvent doesn't bring up the menu, so I am still looking for any workaround, not just a cleaner one.

David