On 5/24/10, Steven Sproat <
spr...@gmail.com> wrote:
>
>> Yes, I am trying to attach to functions; in fact, my window has no
>> menuBar object at all, and it will likely not have one anytime soon
>> (it does not need one). In my app, I tried both wx.NewId() as well as
>> Python's id(self.my_function), but neither worked.
>> self.hotkeyList=[(wx.ACCEL_CTRL, wx.WXK_RETURN, id(self.test))]
>> self.hotkeys=wx.AcceleratorTable(self.hotkeyList)
>> self.parentFrame.SetAcceleratorTable(self.hotkeys)
>>
>> Pressing ctrl-enter in my app does nothing at all, not even causing an
>> exception. I have also tried this:
>> tid=wx.NewId()
>> self.parentFrame.Bind(wx.EVT_KEY_DOWN, self.test, id=tid)
>> and then put "tid" into my table instead of id(test).
>> As I see it, the problem is that I am not telling Python that
>> self.test() and the integer I am generating are one and the same, and
>> I do not know how to do this.
>>
> I think this is what you want:
>
> import wx
>
> class TestFrame(wx.Frame):
> def __init__(self):
> wx.Frame.__init__(self, None)
> _id = wx.NewId()
> hotkeyList = [(wx.ACCEL_CTRL, wx.WXK_RETURN, _id)]