+ def fromstring(self, value):
+ return [int(x) for x in value.split(self.seperator)]
+
+class ConfigIP(ConfigSequence):
+ def __init__(self, default):
+ ConfigSequence.__init__(self, seperator = ".", limits = [(0,255),(0,255),(0,255),(0,255)], default = default)
+
+ def getHTML(self, id):
+ # we definitely don't want leading zeros
+ return '.'.join(["%d" % d for d in self.value])
+
+class ConfigMAC(ConfigSequence):
+ def __init__(self, default):
+ ConfigSequence.__init__(self, seperator = ":", limits = [(1,255),(1,255),(1,255),(1,255),(1,255),(1,255)], default = default)
+
+class ConfigPosition(ConfigSequence):
+ def __init__(self, default, args):
+ ConfigSequence.__init__(self, seperator = ",", limits = [(0,args[0]),(0,args[1]),(0,args[2]),(0,args[3])], default = default)
+
+class ConfigClock(ConfigSequence):
+ def __init__(self, default):
+ import time
+ t = time.localtime(default)
+ ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min])
+
+class ConfigInteger(ConfigSequence):
+ def __init__(self, default, limits = (0, 10000000000)):
+ ConfigSequence.__init__(self, seperator = ":", limits = [limits], default = default)
+
+ # you need to override this to do input validation
+ def setValue(self, value):
+ self._value = [value]
+ self.changed()
+
+ def getValue(self):
+ return self._value[0]
+
+ value = property(getValue, setValue)
+
+ def fromstring(self, value):
+ return int(value)
+
+ def tostring(self, value):
+ return str(value)
+
+class ConfigPIN(ConfigInteger):
+ def __init__(self, default, len = 4, censor = ""):
+ assert isinstance(default, int), "ConfigPIN default must be an integer"
+ if default == -1:
+ default = "aaaa"
+ ConfigSequence.__init__(self, seperator = ":", limits = [(0, (10**len)-1)], censor_char = censor, default = default)
+ self.len = len
+
+ def getLength(self):
+ return self.len
+
+class ConfigFloat(ConfigSequence):
+ def __init__(self, default, limits):
+ ConfigSequence.__init__(self, seperator = ".", limits = limits, default = default)
+
+ def getFloat(self):
+ return float(self.value[1] / float(self.limits[1][1] + 1) + self.value[0])
+
+ float = property(getFloat)
+
+# an editable text...
+class ConfigText(ConfigElement, NumericalTextInput):
+ def __init__(self, default = "", fixed_size = True, visible_width = False):
+ ConfigElement.__init__(self)
+ NumericalTextInput.__init__(self, nextFunc = self.nextFunc, handleTimeout = False)