3 ###################################################
4 ##Variable Config block:
5 ## a variable that reads and writes to a config file
6 ###################################################
9 <name>Variable Config</name>
10 <key>variable_config</key>
11 <import>import ConfigParser</import>
12 <var_make>self._$(id)_config = ConfigParser.ConfigParser()
13 self._$(id)_config.read($config_file)
14 if not self._$(id)_config.has_section($section):
15 self._$(id)_config.add_section($section)
16 try: $(id) = self._$(id)_config.$(type.get)($section, $option)
17 except: $(id) = $value
18 self.$(id) = $(id)</var_make>
20 <callback>self.set_$(id)($value)</callback>
21 <callback>self._$(id)_config.set($section, $option, str($writeback))
22 self._$(id)_config.write(open($config_file, 'w'))</callback>
24 <name>Default Value</name>
37 <opt>get:getfloat</opt>
47 <opt>get:getbool</opt>
56 <name>Config File</name>
57 <key>config_file</key>
58 <value>default</value>
59 <type>file_open</type>
74 <name>WriteBack</name>
80 This block represents a variable that can be read from a config file.
82 To save the value back into the config file: \
83 enter the name of another variable into the writeback param. \
84 When the other variable is changed at runtime, the config file will be re-written.