1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Rep Power

    wxPython + Keyboard Shortcut

    Is it possible to make a Function to be triggered by keyboard shortcut without associating it with menu in wxPython? For eg. I want the program to do something when the user press Alt+K but doesn't have the menu for it.
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Cambridge, UK
    Rep Power
    You can assign a keyboard event to any control not just menus:

    EVT_CHAR(control,callback function )

    The callback function will examine the keypress (one of the event attributes) and will do something with it or pass it on for handling by another event handler.

    Typically the callback function will parse all key presses and only acts on the keys it is interested in - so you normally have a series of if ... elsif ... else statements.

    Note: you would probably attach the handler to a menu's parent to ensure your handler gets a chance to see the key press.

    Last edited by Grim Archon; June 19th, 2004 at 11:18 AM.

IMN logo majestic logo threadwatch logo seochat tools logo