add digitCount to init
authorRonny Strutz <ronny.strutz@multimedia-labs.de>
Fri, 2 Sep 2005 13:39:12 +0000 (13:39 +0000)
committerRonny Strutz <ronny.strutz@multimedia-labs.de>
Fri, 2 Sep 2005 13:39:12 +0000 (13:39 +0000)
add some code for navigate in ConfigSequence
-pls check this, actual its more an ip field and not very flexible
-perhaps nav in field is better done in C++?

lib/python/Components/Network.py
lib/python/Components/config.py

index ab89d3c614936052e0e4a8a5ece8ba291aff299c..3740e51b1593298503b3e339be529e94be0fdcdb 100644 (file)
@@ -23,10 +23,10 @@ class Network:
                
 def InitNetwork():
        config.network = ConfigSubsection()
                
 def InitNetwork():
        config.network = ConfigSubsection()
-       config.network.ip = configElement("config.network.ip", configSequence, [192,168,1,45], ("."))
-       config.network.gateway = configElement("config.network.gateway", configSequence, [192,168,1,3], ("."))
-       config.network.dns = configElement("config.network.dns", configSequence, [192,168,1,3], ("."))
-       config.network.mac = configElement("config.network.mac", configSequence, [00,11,22,33,44,55], (":"))
+       config.network.ip = configElement("config.network.ip", configSequence, [192,168,1,45], (("."), 3))
+       config.network.gateway = configElement("config.network.gateway", configSequence, [192,168,1,3], (("."), 3))
+       config.network.dns = configElement("config.network.dns", configSequence, [192,168,1,3], (("."), 3))
+       config.network.mac = configElement("config.network.mac", configSequence, [00,11,22,33,44,55], ((":"), 2))
 
        iNetwork = Network()
 
 
        iNetwork = Network()
 
index 237e0bf8aa56f1bc68ad1afafb2d71e14f3f8682..e8376385a691d5d5a16b8f5aa29599b50f3cf6ec 100644 (file)
@@ -81,15 +81,17 @@ class configBoolean:
 class configSequence:
        def __init__(self, parent):
                self.parent = parent
 class configSequence:
        def __init__(self, parent):
                self.parent = parent
+               self.markedPos = 0
                
        def checkValues(self):
                
        def checkValues(self):
-               pass
-#              if self.parent.value < 0:
-#                      self.parent.value = 0   
-#
-#              if(self.parent.value >= (len(self.parent.vals) - 1)):
-#                      self.parent.value = len(self.parent.vals) - 1
-#
+               maxPos = len(self.parent.value) * self.parent.vals[1] 
+               print maxPos
+                       
+               if self.markedPos >= maxPos:
+                       self.markedPos = maxPos - 1
+               if self.markedPos < 0:
+                       self.markedPos = 0
+                       
        def cancel(self):
                self.parent.reload()
 
        def cancel(self):
                self.parent.reload()
 
@@ -97,21 +99,39 @@ class configSequence:
                self.parent.save()
 
        def handleKey(self, key):
                self.parent.save()
 
        def handleKey(self, key):
+               #this will no change anything on the value itself
+               #so we can handle it here in gui element
                if key == config.prevElement:
                if key == config.prevElement:
-                       self.parent.value = self.parent.value - 1
+                       self.markedPos -= 1
                if key == config.nextElement:
                if key == config.nextElement:
-                       self.parent.value = self.parent.value + 1
+                       self.markedPos += 1
                
                self.checkValues()                      
                
                self.checkValues()                      
+               
+               print "markPos:",
+               print self.markedPos
 
 
+               #FIXME: dont call when press left/right
                self.parent.change()    
 
        def __call__(self):                     #needed by configlist
                self.parent.change()    
 
        def __call__(self):                     #needed by configlist
+               print "__CALL__"
                value = ""
                value = ""
+               mPos = self.markedPos
+               print mPos
                for i in self.parent.value:
                for i in self.parent.value:
-                       if value != "":
-                               value += self.parent.vals
-                       value += str(i)
+                       if value != "": #fixme no heading separator possible
+                               value += self.parent.vals[0]
+                               if mPos >= len(value) - 1:
+                                       mPos += 1
+                               
+                       diff =  self.parent.vals[1] - len(str(i))
+                       if diff > 0:
+                               #how about alignment?
+                               value += "           "[0:diff]          #how is this done correct?
+                       value +=        str(i)
+               
+               value = value[0:mPos] + "_" + value[mPos + 1:]
                return ("text", value)
 
 class configValue:
                return ("text", value)
 
 class configValue:
@@ -172,7 +192,7 @@ class configElement:
                        return int(data);
                elif control == configSequence:
                        list = [ ]
                        return int(data);
                elif control == configSequence:
                        list = [ ]
-                       part = data.split(self.vals)
+                       part = data.split(self.vals[0])
                        for x in part:
                                list.append(int(x))
                        return list
                        for x in part:
                                list.append(int(x))
                        return list
@@ -188,7 +208,7 @@ class configElement:
                        value = ""
                        for i in data:
                                if value !="":
                        value = ""
                        for i in data:
                                if value !="":
-                                       value += self.vals
+                                       value += self.vals[0]
                                value += str(i)
                        return value
                else: 
                                value += str(i)
                        return value
                else: