我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用wx.WXK_UP。
def on_key_event(self, event): """ Respond to a keypress event. We make the arrow keys move the selected object(s) by one pixel in the given direction. """ step = 1 if event.ControlDown(): step = 20 if event.GetKeyCode() == wx.WXK_UP: self.move_elements(0, -step) elif event.GetKeyCode() == wx.WXK_DOWN: self.move_elements(0, step) elif event.GetKeyCode() == wx.WXK_LEFT: self.move_elements(-step, 0) elif event.GetKeyCode() == wx.WXK_RIGHT: self.move_elements(step, 0) elif event.GetKeyCode() == wx.WXK_DELETE: self.do_cut() else: event.Skip()
def OnKeyDown(self, event): if self.shell.AutoCompActive(): event.Skip() return key = event.GetKeyCode() if key == wx.WXK_RETURN: self.ih = 0 self.shell.processLine() self.shell.clearCommand() elif key == wx.WXK_UP: if self.ih < len(self.shell.history): self.ih += 1 self.shell.clearCommand() self.shell.write(self.shell.history[(self.ih-1)]) elif key == wx.WXK_DOWN: self.shell.clearCommand() self.ih -= 1 if self.ih > 0: self.shell.write(self.shell.history[self.ih - 1]) else: self.ih = 0 else: event.Skip()
def OnKeyDown(self, event): """ Called when key is pressed in SearchCtrl text control @param event: wx.KeyEvent """ # Get event keycode and value in SearchCtrl keycode = event.GetKeyCode() search_value = self.SearchCtrl.GetValue() # Up key was pressed and SearchCtrl isn't empty, search for block in # 'previous' mode if keycode == wx.WXK_UP and search_value != "": self.SearchInTree(search_value, "previous") # Down key was pressed and SearchCtrl isn't empty, search for block in # 'next' mode elif keycode == wx.WXK_DOWN and search_value != "": self.SearchInTree(search_value, "next") # Handle key normally else: event.Skip()
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 OnKeyDown(self, event): """ Do some work when the user press on the keys: up and down: move the cursor """ keycode = event.GetKeyCode() if keycode in [wx.WXK_DOWN, wx.WXK_UP]: self.PopupListBox() if keycode == wx.WXK_DOWN: self.listbox.MoveSelection(1) else: self.listbox.MoveSelection(-1) elif keycode in [wx.WXK_LEFT, wx.WXK_RIGHT, wx.WXK_RETURN] and self.listbox is not None: selected = self.listbox.GetSelection() if selected != "": self.SetValueFromSelected(selected) else: event.Skip() elif event.GetKeyCode() == wx.WXK_ESCAPE: self.DismissListBox() else: event.Skip()
def OnKeyUp(self, event): event.Skip() if not self.selectedNode or not self.hot_map: return if event.KeyCode == wx.WXK_HOME: self.SetSelected(HotMapNavigator.firstNode(self.hot_map)) return elif event.KeyCode == wx.WXK_END: self.SetSelected(HotMapNavigator.lastNode(self.hot_map)) return parent, children, index = HotMapNavigator.findNode(self.hot_map, self.selectedNode) if event.KeyCode == wx.WXK_DOWN: self.SetSelected(HotMapNavigator.nextChild(children, index)) elif event.KeyCode == wx.WXK_UP: self.SetSelected(HotMapNavigator.previousChild(children, index)) elif event.KeyCode == wx.WXK_RIGHT: self.SetSelected(HotMapNavigator.firstChild(children, index)) elif event.KeyCode == wx.WXK_LEFT and parent: self.SetSelected(parent) elif event.KeyCode == wx.WXK_RETURN: wx.PostEvent(self, SquareActivationEvent(node=self.selectedNode, map=self))
def wxglutkeypress(event, special, key): translation = { wx.WXK_UP : GLUT_KEY_UP, wx.WXK_DOWN : GLUT_KEY_DOWN, \ wx.WXK_LEFT : GLUT_KEY_LEFT, wx.WXK_RIGHT : GLUT_KEY_RIGHT, \ wx.WXK_INSERT : GLUT_KEY_INSERT, wx.WXK_DELETE : GLUT_KEY_DELETE} if event.GetKeyCode() in translation: special(translation[event.GetKeyCode()], event.GetPosition().x, event.GetPosition().y) else: code = event.GetKeyCode() if code < 255: k = '%c' % code if not event.GetModifiers() & wx.MOD_SHIFT: k = k.lower() key(k, event.GetPosition().x, event.GetPosition().y)
def OnKeyUp(self, event): event.Skip() if not self.selectedNode or not self.hot_map: return if event.KeyCode == wx.WXK_HOME: self.SetSelected(HotMapNavigator.firstNode(self.hot_map)) return elif event.KeyCode == wx.WXK_END: self.SetSelected(HotMapNavigator.lastNode(self.hot_map)) return try: parent, children, index = HotMapNavigator.findNode(self.hot_map, self.selectedNode) except TypeError: log.info( 'Unable to find hot-map record for node %s', self.selectedNode ) else: if event.KeyCode == wx.WXK_DOWN: self.SetSelected(HotMapNavigator.nextChild(children, index)) elif event.KeyCode == wx.WXK_UP: self.SetSelected(HotMapNavigator.previousChild(children, index)) elif event.KeyCode == wx.WXK_RIGHT: self.SetSelected(HotMapNavigator.firstChild(children, index)) elif event.KeyCode == wx.WXK_LEFT and parent: self.SetSelected(parent) elif event.KeyCode == wx.WXK_RETURN: wx.PostEvent(self, SquareActivationEvent(node=self.selectedNode, map=self))
def onKeyDown(self,event): keyCode = event.GetKeyCode() if keyCode==wx.WXK_UP: self.doMove(*self.slideUpDown(True)) elif keyCode==wx.WXK_DOWN: self.doMove(*self.slideUpDown(False)) elif keyCode==wx.WXK_LEFT: self.doMove(*self.slideLeftRight(True)) elif keyCode==wx.WXK_RIGHT: self.doMove(*self.slideLeftRight(False))
def OnKeyDown(self, event): key_handled = False keycode = event.GetKeyCode() if keycode == wx.WXK_TAB: row = self.GetGridCursorRow() col = self.GetGridCursorCol() if event.ShiftDown(): if row < 0 or col == 0: self.Navigate(wx.NavigationKeyEvent.IsBackward) key_handled = True elif row < 0 or col == self.Table.GetNumberCols() - 1: self.Navigate(wx.NavigationKeyEvent.IsForward) key_handled = True elif keycode in (wx.WXK_ADD, wx.WXK_NUMPAD_ADD) and self.Editable: self.AddRow() key_handled = True elif keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE) and self.Editable: self.DeleteRow() key_handled = True elif keycode == wx.WXK_UP and event.ShiftDown() and self.Editable: self.MoveRow(self.GetGridCursorRow(), -1) key_handled = True elif keycode == wx.WXK_DOWN and event.ShiftDown() and self.Editable: self.MoveRow(self.GetGridCursorRow(), 1) key_handled = True if not key_handled: event.Skip()
def OnChar(self, event): if self.GetDrawingMode() == FREEDRAWING_MODE: Viewer.OnChar(self, event) else: xpos, ypos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL) xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL) ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL) keycode = event.GetKeyCode() if keycode == wx.WXK_DELETE and self.SelectedElement: if self.IsBlock(self.SelectedElement): self.SelectedElement.Delete() elif self.IsWire(self.SelectedElement): self.DeleteWire(self.SelectedElement) elif isinstance(self.SelectedElement, Graphic_Group): all_wires = True for element in self.SelectedElement.GetElements(): all_wires &= self.IsWire(element) if all_wires: self.DeleteWire(self.SelectedElement) else: self.SelectedElement.Delete() self.RefreshBuffer() self.RefreshScrollBars() self.Refresh(False) elif keycode == wx.WXK_LEFT: if event.ControlDown() and event.ShiftDown(): self.Scroll(0, ypos) elif event.ControlDown(): self.Scroll(max(0, xpos - 1), ypos) elif keycode == wx.WXK_RIGHT: if event.ControlDown() and event.ShiftDown(): self.Scroll(xmax, ypos) elif event.ControlDown(): self.Scroll(min(xpos + 1, xmax), ypos) elif keycode == wx.WXK_UP: if event.ControlDown() and event.ShiftDown(): self.Scroll(xpos, 0) elif event.ControlDown(): self.Scroll(xpos, max(0, ypos - 1)) elif keycode == wx.WXK_DOWN: if event.ControlDown() and event.ShiftDown(): self.Scroll(xpos, ymax) elif event.ControlDown(): self.Scroll(xpos, min(ypos + 1, ymax)) else: event.Skip() # ------------------------------------------------------------------------------- # Model adding functions from Drop Target # -------------------------------------------------------------------------------