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'))


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to