Esempio n. 1
0
 def _load_state(self):
     """ 
     Loads saved application state, if possible.  Overload the envisage-
     defined one to fix a py3k bug and increment the TasksApplicationState
     version.
      
     """
     state = TasksApplicationState(version = 2)
     filename = os.path.join(self.state_location, 'application_memento')
     if os.path.exists(filename):
         # Attempt to unpickle the saved application state.
         try:
             with open(filename, 'rb') as f:
                 restored_state = pickle.load(f)
             if state.version == restored_state.version:
                 state = restored_state
                  
                 # make sure the active task is the main window
                 state.previous_window_layouts[0].active_task = 'edu.mit.synbio.cytoflowgui.flow_task'
             else:
                 logger.warn('Discarding outdated application layout')
         except:
             # If anything goes wrong, log the error and continue.
             logger.exception('Had a problem restoring application layout from %s',
                              filename)
               
     self._state = state
Esempio n. 2
0
        def _envisage_load_state(self):
            """ Loads saved application state, if possible.
            """
            state = TasksApplicationState()
            filename = os.path.join(self.state_location, 'application_memento')
            if os.path.exists(filename):
                # Attempt to unpickle the saved application state.
                try:
                    with open(filename, 'rb') as f:
                        restored_state = pickle.load(f)
                    if state.version == restored_state.version:
                        state = restored_state
                    else:
                        logger.warn('Discarding outdated application layout')
                except:
                    # If anything goes wrong, log the error and continue.
                    logger.exception('Restoring application layout from %s',
                                     filename)

            self._state = state