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
try: $(id) = self._$(id)_config.$(type.get)($section, $option)
15
except: $(id) = $value
16
self.$(id) = $(id)</var_make>
18
<callback>self.set_$(id)($value)</callback>
19
<callback>self._$(id)_config = ConfigParser.ConfigParser()
20
self._$(id)_config.read($config_file)
21
if not self._$(id)_config.has_section($section):
22
self._$(id)_config.add_section($section)
23
self._$(id)_config.set($section, $option, str($writeback))
24
self._$(id)_config.write(open($config_file, 'w'))</callback>
26
<name>Default Value</name>
39
<opt>get:getfloat</opt>
49
<opt>get:getbool</opt>
58
<name>Config File</name>
59
<key>config_file</key>
60
<value>default</value>
61
<type>file_open</type>
76
<name>WriteBack</name>
82
This block represents a variable that can be read from a config file.
84
To save the value back into the config file: \
85
enter the name of another variable into the writeback param. \
86
When the other variable is changed at runtime, the config file will be re-written.