Guest User

Untitled

a guest
Jun 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. def StartingKey(self, evt):
  2. """
  3. If the editor is enabled by pressing keys on the grid, this will be
  4. called to let the editor do something about that first key if desired.
  5. """
  6. self.log.write("MyCellEditor: StartingKey %d\n" % evt.GetKeyCode())
  7. key = evt.GetKeyCode()
  8. ch = None
  9. if key in [ wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
  10. wx.WXK_NUMPAD4, wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7,
  11. wx.WXK_NUMPAD8, wx.WXK_NUMPAD9
  12. ]:
  13.  
  14. ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
  15.  
  16. elif key < 256 and key >= 0 and chr(key) in string.printable:
  17. ch = chr(key)
  18.  
  19. if ch is not None:
  20. # For this example, replace the text. Normally we would append it.
  21. #self._tc.AppendText(ch)
  22. self._tc.SetValue(ch)
  23. self._tc.SetInsertionPointEnd()
  24. else:
  25. evt.Skip()
Add Comment
Please, Sign In to add comment