【wxpython】如何设置快捷键
下面写的只能相应方向键,但我想实现ctrl+方向键,应该怎么写?
self.stringtext.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.sizer.Hide(self.bsizer)
self.SetClientSize((650,40))
elif keycode == wx.WXK_DOWN:
self.sizer.Show(self.bsizer)
self.SetClientSize((650,520))
self.OpenRead()
else:
event.Skip() wxpython 快捷键
[解决办法]
养成习惯自己查文档,wxKeyEvent继承wxKeyboardState,后者有一些你要的相关函数...
http://wxpython.org/Phoenix/docs/html/KeyEvent.html?highlight=keyevent#KeyEvent
http://wxpython.org/Phoenix/docs/html/KeyboardState.html#keyboardstate
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
ctrldown = event.ControlDown()
if keycode == wx.WXK_UP and ctrldown:
...