[Tutor] ConfigParser re-read fails
Timo
timomlists at gmail.com
Thu Feb 12 19:25:59 CET 2009
Hello all,
I use a file for my program that I read with ConfigParser. I append all
sections of this file into a treeview (using pyGTK). The user can add,
edit or remove sections, options and values. These I write back to the
file and then update the treeview. The problem is that it doesn't
update, the values are still the same. How can I re-read the
configuration file?
This is (very simple) what I do:
conf = ConfigParser.RawConfigParser()
configFile = 'config.cfg'
conf.read(configFile)
fill_treeview()
def fill_treeview()
# Do the treeview stuff here
def button_clicked()
write_config(section, option, value)
conf.read(configFile) # It needs to be re-read here
fill_treeview()
def write_config(section, option, value)
if not conf.has_section(section):
conf.add_section(section)
conf.set(section, key, value)
conf.write(open(configFile, 'w'))
More information about the Tutor
mailing list