Python wx 模块,WXK_DELETE 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用wx.WXK_DELETE

项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
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
项目:tindieorderprintout    作者:limpkin    | 项目源码 | 文件源码
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()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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()
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def on_run(self, event):
        code = event.GetKeyCode()
        title = self.buf[event.GetIndex()][0]
        txt = self.buf[event.GetIndex()][1]
        if code == wx.WXK_DELETE:
            txt = ''
        elif code == wx.WXK_CONTROL: 
            txt = self.ist(txt, 'Ctrl')
        elif code == wx.WXK_ALT: 
            txt = self.ist(txt, 'Alt')
        elif code == wx.WXK_SHIFT: 
            txt = self.ist(txt, 'Shift')
        elif code in range(340,352):
            fs = ['F'+str(i) for i in range(1,13)]
            txt = self.ist(txt, fs[code-340])
        elif code<100: 
            txt = self.ist(txt, chr(event.GetKeyCode()))
        if len(txt)>0 and txt[-1]=='-':txt=txt[:-1]
        self.buf[event.GetIndex()][1] = txt
        self.lst_plgs.RefreshItem(event.GetIndex())
        if txt=='':ShotcutManager.rm(title)
        ShotcutManager.set(title, txt)
        #PluginsManager.plgs[self.buf[event.GetIndex()][0]]().start()
项目:pypilot    作者:pypilot    | 项目源码 | 文件源码
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)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnKeyListItem(self, event):
        keycode = event.GetKeyCode()
        itemcount = self.mainlist.GetItemCount()
        if keycode == wx.WXK_DELETE and itemcount > 0:
            self.mainlist.DeleteItem(self.CurrentListItem)
            self.pipelineitems[self.CurrentListItem].Hide()
            self.pipelineitems.pop(self.CurrentListItem)
            if len(self.pipelineitems) == 0:
                self.menu_place_holder.Show()
            next = self.CurrentListItem - 1
            self.mainlist.SetItemState(next, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED )
        event.Skip()
项目:Turrican2Editor    作者:GitExl    | 项目源码 | 文件源码
def key_char(self, key_code):
        if key_code == wx.WXK_DELETE:
            self.delete_entities()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnDeleteMenu(self, event):
        window = self.FindFocus()
        if window == self.ProjectTree or window is None:
            selected = self.ProjectTree.GetSelection()
            if selected is not None and selected.IsOk():
                function = self.DeleteFunctions.get(self.ProjectTree.GetPyData(selected)["type"], None)
                if function is not None:
                    function(self, selected)
                    self.CloseTabsWithoutModel()
                    self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE,
                                  POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
        elif isinstance(window, (Viewer, TextViewer)):
            event = wx.KeyEvent(wx.EVT_CHAR._getEvtType())
            event.m_keyCode = wx.WXK_DELETE
            window.ProcessEvent(event)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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()
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def  onKeyPress(self,event):

        global SUBJECT
        if self.IsRangeSelected:
            if event.ControlDown() and event.GetKeyCode() == 67: # Ctrl + C
                #print "Ctrl+C"
                self.Copy()
                self.dataObj = wx.TextDataObject()
                self.dataObj.SetText("hello")
                #print "text ",self.dataObj.GetText()#self.text.GetValue())



            elif event.ControlDown() and event.GetKeyCode() == 88: #Ctrl X
                #print "ctrl x"
                self.Copy()
                self.Delete()



            if event.GetKeyCode()==wx.WXK_DELETE :


                self.Delete()

        if event.ControlDown() and event.GetKeyCode() == 86: #CTRl +V

                self.Paste()

        elif event.ControlDown() and event.GetKeyCode() == 83: #Ctrl s

                if self.button_1.Enabled==True:

                    self.Save_Clicked(None)# invoking save_clicked event



        event.Skip()
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def on_keydown_contacts(self,event):
        keycode=event.GetKeyCode()
        if keycode==wx.WXK_BACK or keycode==wx.WXK_CANCEL or keycode==wx.WXK_CLEAR or keycode==wx.WXK_DELETE or keycode==wx.WXK_DOWN or keycode==wx.WXK_END or keycode==wx.WXK_LBUTTON :

            event.Skip()
            return 0
        elif keycode==wx.WXK_NUMPAD_END or keycode==wx.WXK_NUMPAD_NEXT or keycode==wx.WXK_NUMPAD_RIGHT or keycode==wx.WXK_RIGHT or keycode==wx.WXK_LEFT or keycode==wx.WXK_NEXT or keycode==wx.WXK_NUMPAD_DELETE or keycode==wx.WXK_NUMPAD_LEFT:
            event.Skip()
            return 0

        character=chr(keycode)
        if character.isdigit() or character==';':
            event.Skip()
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def onTextKeyEvent(self, event):
        keycode = event.GetKeyCode()
        print(keycode)
        if keycode == wx.WXK_DELETE:
            print("you pressed the delete key!")
        event.Skip()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnKeyPressed(self, event):
        if self.CallTipActive():
            self.CallTipCancel()
        key = event.GetKeyCode()
        current_pos = self.GetCurrentPos()
        selected = self.GetSelection()
        text_selected = selected[0] != selected[1]

        # Test if caret is before Windows like new line
        text = self.GetText()
        if current_pos < len(text) and ord(text[current_pos]) == 13:
            newline_size = 2
        else:
            newline_size = 1

        # Disable to type any character in section header lines
        if (self.GetLineState(self.LineFromPosition(current_pos)) and
            not text_selected and
            key not in NAVIGATION_KEYS + [
                wx.WXK_RETURN,
                wx.WXK_NUMPAD_ENTER]):
            return

        # Disable to delete line between code and header lines
        elif (self.GetCurLine()[0].strip() != "" and not text_selected and
              (key == wx.WXK_BACK and
               self.GetLineState(self.LineFromPosition(max(0, current_pos - 1))) or
               key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE] and
               self.GetLineState(self.LineFromPosition(min(len(text), current_pos + newline_size))))):
            return

        elif key == 32 and event.ControlDown():
            pos = self.GetCurrentPos()

            # Tips
            if event.ShiftDown():
                pass
            # Code completion
            else:
                self.AutoCompSetIgnoreCase(False)  # so this needs to match

                keywords = self.KEYWORDS + [var["Name"]
                                            for var in self.Controler.GetVariables()]
                keywords.sort()
                self.AutoCompShow(0, " ".join(keywords))
        else:
            event.Skip()