Python wx.WXK_SPACE Examples

The following are 10 code examples of wx.WXK_SPACE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: APDUHexValidator.py    From pyscard with GNU Lesser General Public License v2.1 6 votes vote down vote up
def OnChar(self, event):
        key = event.GetKeyCode()

        if wx.WXK_SPACE == key or chr(key) in string.hexdigits:
            value = event.GetEventObject().GetValue() + chr(key)
            if apduregexp.match(value):
                event.Skip()
            return

        if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255:
            event.Skip()
            return

        if not wx.Validator_IsSilent():
            wx.Bell()

        return 
Example #2
Source File: DigitOnlyValidator.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def OnChar(self, event):
        key = event.GetKeyCode()

        if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255:
            event.Skip()
            return

        if chr(key) in string.digits:
            event.Skip()
            return

        if not wx.Validator_IsSilent():
            wx.Bell()

        # Returning without calling event.Skip eats the event before it
        # gets to the text control
        return 
Example #3
Source File: CustomEditableListBox.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #4
Source File: util.py    From trelby with GNU General Public License v2.0 5 votes vote down vote up
def toStr(self):
        s = ""

        if self.ctrl:
            s += "CTRL+"

        if self.alt:
            s += "ALT+"

        if self.shift:
            s += "SHIFT+"

        if isValidInputChar(self.kc):
            if self.kc == wx.WXK_SPACE:
                s += "Space"
            else:
                s += chr(self.kc)
        else:
            kname = self.__class__.keyMap.get(self.kc)

            if kname:
                s += kname
            else:
                s += "UNKNOWN(%d)" % self.kc

        return s

# a string-like object that features reasonably fast repeated appends even
# for large strings, since it keeps each appended string as an item in a
# list. 
Example #5
Source File: Util.py    From pyResMan with GNU General Public License v2.0 5 votes vote down vote up
def OnChar(self, event):
        """Process values as they are entered into the control
        @param event: event that called this handler

        """
        key = event.GetKeyCode()
        if event.CmdDown() or key < wx.WXK_SPACE or key == wx.WXK_DELETE or \
           key > 255 or chr(key) in Util.HEXCHARS:
            event.Skip()
            return

        if not wx.Validator_IsSilent():
            wx.Bell()

        return 
Example #6
Source File: viewer.py    From GraphLayout with MIT License 5 votes vote down vote up
def on_char(self, event):
        event.Skip()
        if event.GetKeyCode() == wx.WXK_ESCAPE:
            self.GetParent().Close()
        elif event.GetKeyCode() == wx.WXK_SPACE:
            self.next() 
Example #7
Source File: __init__.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def text_inserted(self, event):
        key = event.KeyCode()

        if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255:
            event.Skip()
            return

        if (self.valid_chars is not None) and (chr(key) not in self.valid_chars):
            return

        event.Skip() 
Example #8
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def OnChar(self, event):
        key = event.KeyCode

        if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255:
            event.Skip()
            return

        textCtrl = self.GetWindow()
        startPos, endPos = textCtrl.GetSelection()
        length = textCtrl.GetLastPosition() - (endPos - startPos)
        if length >= self.maxLength:
            if not wx.Validator_IsSilent():
                wx.Bell()
            return

        if(
            self.allowRaw
            and textCtrl.GetInsertionPoint() == 0
            and chr(key).upper() == "R"
        ):
            textCtrl.WriteText("R")
            return

        if chr(key) in hexdigits:
            textCtrl.WriteText(chr(key).upper())
            return

        if not wx.Validator_IsSilent():
            wx.Bell()

        # Returning without calling event.Skip eats the event before it
        # gets to the text control
        return 
Example #9
Source File: PouInstanceVariablesPanel.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #10
Source File: ObjectListView.py    From bookhub with MIT License 4 votes vote down vote up
def _HandleChar(self, evt):
        if evt.GetKeyCode() == wx.WXK_F2 and not self.IsCellEditing():
            return self._PossibleStartCellEdit(self.GetFocusedRow(), self.GetPrimaryColumnIndex())

        # We have to catch Return/Enter/Escape here since some types of controls
        # (e.g. ComboBox, UserControl) don't trigger key events that we can listen for.
        # Treat Return or Enter as committing the current edit operation unless the control
        # is a multiline text control, in which case we treat it as data
        if evt.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER) and self.IsCellEditing():
            if self.cellEditor and self.cellEditor.HasFlag(wx.TE_MULTILINE):
                return evt.Skip()
            else:
                return self.FinishCellEdit()

        # Treat Escape as cancel the current edit operation
        if evt.GetKeyCode() in (wx.WXK_ESCAPE, wx.WXK_CANCEL) and self.IsCellEditing():
            return self.CancelCellEdit()

        # Tab to the next editable column
        if evt.GetKeyCode() == wx.WXK_TAB and self.IsCellEditing():
            return self._HandleTabKey(evt.ShiftDown())

        # Space bar with a selection on a listview with checkboxes toggles the checkboxes
        if (evt.GetKeyCode() == wx.WXK_SPACE and
            not self.IsCellEditing() and
            self.checkStateColumn is not None and
            self.GetSelectedItemCount() > 0):
            return self._ToggleCheckBoxForSelection()

        if not self.IsCellEditing():
            if self._HandleTypingEvent(evt):
                return

        if not self.IsCellEditing() and self.handleStandardKeys:
            # Copy selection on Ctrl-C
            # Why is Ctrl-C represented by 3?! Is this Windows only?
            if (evt.GetKeyCode() == 3):
                self.CopySelectionToClipboard()
                return
            # Select All on Ctrl-A
            if (evt.GetKeyCode() == 1):
                self.SelectAll()
                return

        evt.Skip()