[wxpython-users] accelerator newbie, help
Bernd Kreuss
bernd_kreuss at gmx.net
Thu Apr 24 18:31:27 PDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIETRpxT6R4jlFoh0RAjD1AKCfwQC20h33B+E/mn8gCREIxaV1sQCeJ44v
1La0vajYq4YnqHlFQXcmFKY=
=MNG2
-----END PGP SIGNATURE-----
More information about the wxpython-users
mailing list