<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def apply(self, event = None):

 """Before self.onOk closes the window, it calls this function to sync the config changes from the GUI back to self.config."""

  for section in self.config.sections():
   # Run through the sections to check all the option values:
   for option, o in self.config.config[section].items():
    # Check the actual values against the validators and complain if necessary:
    if not o['include']:
     continue # This value is hidden, so there's no control for it.
    control = self._controls[section][option] # Get the actual control for GetValue
    try:
     value = type(o['value'])(control.GetValue()) # Try and convert the value
    except ValueError as msg:
     self.displayError(section, option, str(msg)) # Woops, something went wrong
     return False # Tells self.onOk not to close the window
    problem = None # Set up the problem variable.
    try:
     problem = o['validate'](value) # See if it passes the test
    except Exception as e:
     problem = str(e) # The lambda raised an exception.
    if problem:
     self.displayError(section, option, problem) # It didn't
     return False # Tells self.onOk not to close the window
    self.config.set(section, option, value) # All clear
  return True