def restore_state(self): ''' restore the state of the gui from the preferences ''' for expander, pref in self.expanders_pref_map.iteritems(): expanded = prefs.get(pref, True) self.widgets[expander].set_expanded(expanded)
def add_to_history(self, text, index=0): """ add text to history, if text is already in the history then set its index to index parameter """ if index < 0 or index > self.history_size: raise ValueError(_("history size must be greater than zero and " "less than the history size")) history = prefs.get(self.entry_history_pref, []) if text in history: history.remove(text) # trim the history if the size is larger than the history_size pref while len(history) >= self.history_size - 1: history.pop() history.insert(index, text) prefs[self.entry_history_pref] = history self.populate_main_entry()
def add_to_history(self, text, index=0): """ add text to history, if text is already in the history then set its index to index parameter """ if index < 0 or index > self.history_size: raise ValueError(_('history size must be greater than zero and ' 'less than the history size')) history = prefs.get(self.entry_history_pref, []) if text in history: history.remove(text) # trim the history if the size is larger than the history_size pref while len(history) >= self.history_size-1: history.pop() history.insert(index, text) prefs[self.entry_history_pref] = history self.populate_main_entry()