Revision: 5285
Updated Code
at February 24, 2008 23:06 by stagger
Updated Code
import wx import string class HostValidator(wx.PyValidator): def __init__(self, pyVar=None): wx.PyValidator.__init__(self) self.Bind(wx.EVT_CHAR, self.OnChar) def Clone(self): """ Standard cloner. Note that every validator must implement the Clone() method. """ return HostValidator() def Validate(self, win): tc = self.GetWindow() # tc == TextCtrl val = tc.GetValue() for x in val: if x not in string.digits and x not in ".:": return False return True 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 chr(key) in ".:": 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
Revision: 5284
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 24, 2008 23:02 by stagger
Initial Code
Initial URL
Initial Description
Initial Title
GUI Collector - Validator Library
Initial Tags
textmate, python
Initial Language
Python