我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用wx.WXK_SPACE。
def OnChar(self, event): key = event.KeyCode if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255: event.Skip() return if not self.charmap or chr(key) in self.charmap: val = self.GetWindow().GetValue() if not self.maxlength or len(val) < self.maxlength: event.Skip() return if not wx.Validator_IsSilent(): wx.Bell() # Returning without calling even.Skip eats the event before it # gets to the text control return
def OnKeyDown(self, event): button = None keycode = event.GetKeyCode() if keycode in (wx.WXK_ADD, wx.WXK_NUMPAD_ADD): button = self.GetNewButton() elif keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE): button = self.GetDelButton() elif keycode == wx.WXK_UP and event.ShiftDown(): button = self.GetUpButton() elif keycode == wx.WXK_DOWN and event.ShiftDown(): button = self.GetDownButton() elif keycode == wx.WXK_SPACE: button = self.GetEditButton() if button is not None and button.IsEnabled(): button.ProcessEvent(wx.CommandEvent(wx.EVT_BUTTON.typeId, button.GetId())) else: event.Skip()
def BindKeys(self,dbfile): ''' Bind keyboard shortcuts for application. ''' self.Bind(wx.EVT_MENU, lambda event, args=('MENU_DEL',dbfile): self.OnKeyDown(event,args), self.ditem) self.Bind(wx.EVT_MENU, lambda event, args=dbfile: self.Undo(event,args), self.zitem) self.Bind(wx.EVT_BUTTON, lambda event, args=('wx.WXK_SPACE',dbfile): self.OnKeyDown(event,args), self.bplay) self.Bind(wx.EVT_BUTTON, lambda event, args=(dbfile): self.CaptureCanvas(event,args), self.brec) self.panel3.Bind(wx.EVT_KEY_DOWN, lambda event, args=(dbfile): self.OnKeyDown(event, args)) self.panel3.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick) self.Bind(wx.EVT_MENU, lambda event, args=(dbfile):self.OnQuit(event,args), self.qitem) self.Bind(wx.EVT_CLOSE, lambda event, args=(dbfile):self.OnQuit(event,args), self.qitem) self.Bind(wx.EVT_MENU, lambda event, args=(dbfile):self.OnRender(event,args), self.ritem)
def ShowInstanceChoicePopup(self): self.InstanceChoice.SetFocusFromKbd() size = self.InstanceChoice.GetSize() event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) event.x = size.width / 2 event.y = size.height / 2 event.SetEventObject(self.InstanceChoice) # event = wx.KeyEvent(wx.EVT_KEY_DOWN._getEvtType()) # event.m_keyCode = wx.WXK_SPACE self.InstanceChoice.GetEventHandler().ProcessEvent(event)
def onKeyPress(self, event): keycode = event.GetKeyCode() print(keycode) if keycode == wx.WXK_SPACE: print("you pressed the spacebar!") event.Skip()
def onCharEvent(self, event): keycode = event.GetKeyCode() controlDown = event.CmdDown() altDown = event.AltDown() shiftDown = event.ShiftDown() print(keycode) if keycode == wx.WXK_SPACE: print("you pressed the spacebar!") elif controlDown and altDown: print(keycode) event.Skip()
def onButtonKeyEvent(self, event): keycode = event.GetKeyCode() print(keycode) if keycode == wx.WXK_SPACE: print("you pressed the spacebar!") event.Skip()