[wxPython] wxKeyEvent

can someone point me to an example of how to use wxKeyEvent?

specifically, i want to capture when user has pressed 'Ctrl-S'

i've tried using the following macros (defined in my top frame __init__()):

  EVT_CHAR_HOOK(self, self.onCharDown)
  EVT_CHAR(self, self.onCharDown2)
  EVT_KEY_DOWN(self, self.onCharDown3)

for some reason, i can only seem to get EVT_CHAR_HOOK to work (my
understanding is that char_hook is for modifier keys only).

does EVT_CHAR macro only work from a wxWindow or Panel? if so, how do i
capture 'Ctrl-S' key press event from top frame?

thanks,
andrew

can someone point me to an example of how to use wxKeyEvent?

demo/GridEnterHandler.py, as well as others...

specifically, i want to capture when user has pressed 'Ctrl-S'

i've tried using the following macros (defined in my top frame

__init__()):

There's your problem. Only the window with the keyboard focus gets the
CHAR, KEY_DOWN, KEY_UP events, and your frame will never have the focus.
(BTW, you shouldn't use CHAR_HOOK as it's inconsistent and is only there for
legacy reasons.)

does EVT_CHAR macro only work from a wxWindow or Panel? if so, how do i
capture 'Ctrl-S' key press event from top frame?

Use an accelerator table and then hook the event handler to the fram with
EVT_MENU.

    ctrl_s_id = wxNewId()
    aTable = wxAcceleratorTable([ (wxACCEL_CTRL, ord('S'), ctrl_s_id) ])
    self.SetAcceleratorTable(aTable)
    EVT_MENU(self, ctrl_s_id, self.OnCtrlS)

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

in your case its better to use an Accelerator.
show in the demo Example codes of wxPython
for 'wxAcceleratorTable' and learn from then...

        #Accelerator Shortcuts
        aTable = wxAcceleratorTable([ (wxACCEL_NORMAL, WXK_F1,
ID_HELP_HELP) ])
        self.SetAcceleratorTable(aTable)
..
        menu.Append(ID_HELP_ABOUT, "&About",
              "More information about this program")
        EVT_MENU(self, ID_HELP_HELP, self.OnShowHelp)

hope it helps ...
best regards

···

===========================================================
Heinl Raimund SSH - Software Systeme Heinl
gepr.Wirtschaftsinformatiker IHK Am Galling 3
Tel. 09151 / 7 10 99 91217 Hersbruck
Fax. 09151 / 90 50 51
http: coming soon
Email: heinlr@gmx.de

----- Original Message -----
From: "Andrew Yinger" <ayinger1@pacbell.net>
To: <wxpython-users@lists.wxwindows.org>
Sent: Monday, October 22, 2001 12:12 AM
Subject: [wxPython] wxKeyEvent

can someone point me to an example of how to use wxKeyEvent?

specifically, i want to capture when user has pressed 'Ctrl-S'

i've tried using the following macros (defined in my top frame

__init__()):

  EVT_CHAR_HOOK(self, self.onCharDown)
  EVT_CHAR(self, self.onCharDown2)
  EVT_KEY_DOWN(self, self.onCharDown3)

for some reason, i can only seem to get EVT_CHAR_HOOK to work (my
understanding is that char_hook is for modifier keys only).

does EVT_CHAR macro only work from a wxWindow or Panel? if so, how do i
capture 'Ctrl-S' key press event from top frame?

thanks,
andrew

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users