3 self.configElements = { }
5 self.file = open("config")
7 print "cannot open config file"
11 line = self.file.readline()
17 def addElement(self, line):
20 self.configElements[line[:x]] = line[x + 1:]
22 def getKey(self, key):
23 return self.configElements[key]
25 def setKey(self, key, value):
26 self.configElements[key] = value
29 fileHandle = open("config", "w")
31 for x in self.configElements:
32 fileHandle.write(x + "=" + self.configElements[x])
37 def __init__(self, parent):
40 def checkValues(self):
41 if self.parent.value < 0:
44 if(self.parent.value >= (len(self.parent.vals) - 1)):
45 self.parent.value = len(self.parent.vals) - 1
53 def handleKey(self, key):
55 self.parent.value = self.parent.value - 1
57 self.parent.value = self.parent.value + 1
63 def __call__(self): #needed by configlist
65 return ("text", self.parent.vals[self.parent.value])
68 def __init__(self, obj):
79 configfile = configFile()
82 def __init__(self, parent):
91 def checkValues(self):
92 if self.parent.value < 0:
95 if self.parent.value > 10:
96 self.parent.value = 10
98 def handleKey(self, key):
100 self.parent.value = self.parent.value - 1
102 self.parent.value = self.parent.value + 1
107 def __call__(self): #needed by configlist
109 return ("slider", self.parent.value * 10)
111 class ConfigSubsection:
116 def datafromFile(self, control, data):
117 if control == ConfigSlider:
119 elif control == configBoolean:
124 def datatoFile(self, control, data):
125 if control == ConfigSlider:
127 elif control == configBoolean:
134 value = self.datafromFile(self.controlType, configfile.getKey(self.configPath))
139 print "value not found - using default"
140 self.value = self.defaultValue
141 self.save() #add missing value to dict
146 def __init__(self, configPath, control, defaultValue, vals):
147 self.configPath = configPath
148 self.defaultValue = defaultValue
149 self.controlType = control
151 self.notifierList = [ ]
153 def addNotifier(self, notifier):
154 self.notifierList.append(notifier);
157 for notifier in self.notifierList:
162 configfile.setKey(self.configPath, self.datatoFile(self.controlType,self.value))