code: def OnChar(self, event):
          
          key   = event.GetKeyCode()
          entry = wx.TextCtrl.GetValue(self).strip()
          pos   = wx.TextCtrl.GetSelection(self)
          # really, the order here is important:
          # 1. return sends to ValidateEntry
          if key == wx.WXK_RETURN:
              if not self.is_valid:
                  wx.TextCtrl.SetValue(self, self.format % set_float(self.__bound_val))
              else:
                  self.SetValue(entry)
              return
  
          # 2. other non-text characters are passed without change
          if (key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255):
              event.Skip()
              return
  
          # 3. check for multiple '.' and out of place '-' signs and ignore these
          #    note that chr(key) will now work due to return at #2
  
          has_minus = '-' in entry
          ckey = chr(key)
          if ((ckey == '.' and (self.__prec == 0 or '.' in entry) ) or
              (ckey == '-' and (has_minus or  pos[0] != 0)) or
              (ckey != '-' and  has_minus and pos[0] == 0)):
              return
          # 4. allow digits, but not other characters
          if chr(key) in self.__digits:
              event.Skip()
docs: on Character event