accelerator newbie, help

Quoting Phillip Watts <phillip.watts@anvilcom.com>:

I used Mike Driscoll's example of a fake menu to get some
id's for the accelerator table, which apparently must use
to get frame level keyboard events.

All that's needed is an ID, (wx.NewId()) and to use the same ID in the accelerator table and in the Bind statement.

···

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

Robin Dunn wrote:

All that's needed is an ID, (wx.NewId()) and to use the same ID in the
accelerator table and in the Bind statement.

It is the panel! I tried it with a naked frame in my experiments before.
I never thought that a wx.Panel could have any influence. The code below
works as long as the line with the wx.Panel isn't commented out (wxGTK):

#!/usr/bin/python

import wx

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY)
        self.panel = wx.Panel(self, wx.ID_ANY)

        self.Bind(wx.EVT_MENU, self.onSave, id=100)
        self.Bind(wx.EVT_MENU, self.onPrint, id=101)

        accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('S'), 100),
                                         (wx.ACCEL_CTRL, ord('P'), 101)
                                         ])
        self.SetAcceleratorTable(accel_tbl)

        self.Show()

    def onPrint(self, event):
        print 'in onPrint'

    def onSave(self, event):
        print 'in onSave'

- --
private communication within hostile networks:
http://torchat.googlecode.com/