Author: bugman Date: Tue May 22 16:39:47 2012 New Revision: 16393 URL: http://svn.gna.org/viewcvs/relax?rev=16393&view=rev Log: The Combo_list GUI input element ResetChoices() method now remembers the current selection. This allows the selection to be restored when the element is updated, rather than resetting to the default value. Modified: branches/uf_redesign/gui/input_elements/combo_list.py Modified: branches/uf_redesign/gui/input_elements/combo_list.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/input_elements/combo_list.py?rev=16393&r1=16392&r2=16393&view=diff ============================================================================== --- branches/uf_redesign/gui/input_elements/combo_list.py (original) +++ branches/uf_redesign/gui/input_elements/combo_list.py Tue May 22 16:39:47 2012 @@ -320,6 +320,9 @@ # Loop over the combo boxes. for i in range(len(self._combo_boxes)): + # Store the current selection's client data to restore at the end. + sel = self._combo_boxes[i].GetClientData(self._combo_boxes[i].GetSelection()) + # First clear all data. self._combo_boxes[i].Clear() @@ -328,7 +331,7 @@ self._combo_boxes[i].Insert(self.convert_to_gui(self._choices[j]), j, self._data[j]) # Set the default selection. - if self._default != None: + if sel == None and self._default != None: # Translate if needed. if self._default in self._choices: string = self._default @@ -340,6 +343,12 @@ # Set the selection. self._combo_boxes[i].SetStringSelection(string) + # Restore the selection. + else: + for j in range(self._combo_boxes[i].GetCount()): + if self._combo_boxes[i].GetClientData(j) == sel: + self._combo_boxes[i].SetSelection(j) + def SetValue(self, value=None, index=None): """Special method for setting the value of the GUI element.