- def __call__(self, selected): #needed by configlist
- self.checkValues()
- #fixme
- return ("text", str(self.parent.vals[self.parent.value][0]))
-
-class configSequenceArg:
- def get(self, type, args = ()):
- # configsequencearg.get ("IP")
- if (type == "IP"):
- return (("."), [(0,255),(0,255),(0,255),(0,255)], "")
- # configsequencearg.get ("MAC")
- if (type == "POSITION"):
- return ((","), [(0,args[0]),(0,args[1]),(0,args[2]),(0,args[3])], "")
- if (type == "MAC"):
- return ((":"), [(1,255),(1,255),(1,255),(1,255),(1,255),(1,255)], "")
- # configsequencearg.get ("CLOCK")
- if (type == "CLOCK"):
- return ((":"), [(0,23),(0,59)], "")
- # configsequencearg.get("INTEGER", (min, max)) => x with min <= x <= max
- if (type == "INTEGER"):
- return ((":"), [args], "")
- # configsequencearg.get("PINCODE", (number, "*")) => pin with number = length of pincode and "*" as numbers shown as stars
- # configsequencearg.get("PINCODE", (number, "")) => pin with number = length of pincode and numbers shown
- if (type == "PINCODE"):
- return ((":"), [(0, (10**args[0])-1)], args[1])
- # configsequencearg.get("FLOAT", [(min,max),(min1,max1)]) => x.y with min <= x <= max and min1 <= y <= max1
- if (type == "FLOAT"):
- return (("."), args, "")
+ def handleKey(self, key):
+ if key == KEY_LEFT:
+ self.value = self.value - self.increment
+ elif key == KEY_RIGHT:
+ self.value = self.value + self.increment
+ elif key == KEY_HOME or key == KEY_END:
+ self.value = self.default
+
+ def getText(self):
+ return time.strftime(self.formatstring, time.localtime(self.value))
+
+ def getMulti(self, selected):
+ return ("text", time.strftime(self.formatstring, time.localtime(self.value)))
+
+ def fromstring(self, val):
+ return int(val)
+
+# *THE* mighty config element class
+#
+# allows you to store/edit a sequence of values.
+# can be used for IP-addresses, dates, plain integers, ...
+# several helper exist to ease this up a bit.
+#
+class ConfigSequence(ConfigElement):
+ def __init__(self, seperator, limits, censor_char = "", default = None):
+ ConfigElement.__init__(self)
+ assert isinstance(limits, list) and len(limits[0]) == 2, "limits must be [(min, max),...]-tuple-list"
+ assert censor_char == "" or len(censor_char) == 1, "censor char must be a single char (or \"\")"
+ #assert isinstance(default, list), "default must be a list"
+ #assert isinstance(default[0], int), "list must contain numbers"
+ #assert len(default) == len(limits), "length must match"
+
+ self.marked_pos = 0
+ self.seperator = seperator
+ self.limits = limits
+ self.censor_char = censor_char