+
+ def getIndexbyEntry(self, data):
+ cnt = 0;
+ tcnt = -1; #for defaultval
+ for x in self.vals:
+ if int(x[1]) == int(data):
+ return cnt
+ if int(x[1]) == int(self.defaultValue):
+ tcnt = cnt
+ cnt += 1
+ if tcnt != -1:
+ return tcnt
+ return 0 #prevent bigger then array
+
+ def datafromFile(self, control, data):
+ if control == ConfigSlider:
+ return int(data);
+ elif control == configSelection:
+ return int(data);
+ elif control == configSequence:
+ list = [ ]
+ part = data.split(self.vals[0])
+ for x in part:
+ list.append(int(x))
+ return list
+ elif control == configSatlist:
+ return self.getIndexbyEntry(data)
+ else:
+ return ""
+
+ def datatoFile(self, control, data):
+ if control == ConfigSlider:
+ return str(data);
+ elif control == configSelection:
+ return str(data);
+ elif control == configSequence:
+ value = ((len(data) * ("%d" + self.vals[0]))[0:-1]) % tuple(data)
+# just in case you don't understand the above, here an equivalent:
+# value = ""
+# for i in data:
+# if value !="":
+# value += self.vals[0]
+# value += str(i)
+ return value
+ elif control == configSatlist:
+ return str(self.vals[self.value][1]);
+ else:
+ return ""
+
+ def loadData(self):
+ try:
+ value = self.datafromFile(self.controlType, configfile.getKey(self.configPath))
+ except:
+ value = ""
+
+ if value == "":
+ print "value not found - using default"
+
+ if self.controlType == configSatlist:
+ self.value = self.getIndexbyEntry(self.defaultValue)
+ else:
+ self.value = self.defaultValue
+
+ self.save() #add missing value to dict
+ else:
+ self.value = value
+
+ #is this right? activate settings after load/cancel and use default
+ self.change()
+