Hello,
I want to control image processing by key shortcuts. I will try to do that with
wx.AcceleratorTable but I found a strange behavior.
The example below works fine under Linux (Kubuntu Natty, Python 2.7.1, wxPython
2.8.12.0) and WinXP (Python 2.7.2, wxPython 2.8.12.1)
But if you change “.. wx.ACCEL_CTRL, ord('Q')” into “.. wx.ACCEL_NORMAL,
ord('Q')” it works still under WinXP but NOT under Linux.
If I try “.. wx.ACCEL_NORMAL, wx.WXK_F1” it works fine again on both systems.
Does anyone have an explanation for that strange behavior?
import wx
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "Test", size=(100,100))
panel = wx.Panel(self, wx.ID_ANY)
MenuBar = wx.MenuBar()
self.SetMenuBar
randomId = wx.NewId()
self.Bind(wx.EVT_MENU, self.onKey, id=randomId)
accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('q'), randomId )])
self.SetAcceleratorTable(accel_tbl)
def onKey(self, event):
print "You pressed the key!"
if __name__ == "__main__":
app = wx.App(False)
frame = MyForm()
frame.Show()
app.MainLoop()