Author: bugman Date: Wed Jun 6 16:00:11 2012 New Revision: 16699 URL: http://svn.gna.org/viewcvs/relax?rev=16699&view=rev Log: Bug fix for the Combo_list GUI input element - default values in the UpdateChoices() method can be a list. With a default value being a list, this is now properly handled and set in the GUI element. 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=16699&r1=16698&r2=16699&view=diff ============================================================================== --- branches/uf_redesign/gui/input_elements/combo_list.py (original) +++ branches/uf_redesign/gui/input_elements/combo_list.py Wed Jun 6 16:00:11 2012 @@ -194,7 +194,14 @@ # Set the default selection. if self._default: - self._combo_boxes[-1].SetStringSelection(self._default) + # A list. + if isinstance(self._default, list): + if index < len(self._default): + self._combo_boxes[-1].SetStringSelection(self._default[index-1]) + + # Single value. + else: + self._combo_boxes[-1].SetStringSelection(self._default) # The add button. button = None @@ -390,16 +397,38 @@ # Set the default selection. if sel == None and self._default != None: - # Translate if needed. - if self._default in self._choices: - string = self._default - elif self._default not in self._data: - string = self._default + # A list. + if isinstance(self._default, list): + # Add rows as needed. + if len(self._default) > len(self._combo_boxes): + for k in range(len(self._default) - len(self._combo_boxes)): + self._add(None) + + # Loop over the defaults. + for k in range(len(self._default)): + # Translate if needed. + if self._default[k] in self._choices: + string = self._default[k] + elif self._default[k] not in self._data: + string = self._default[k] + else: + string = self._choices[self._data.index(self._default[k])] + + # Set the selection. + self._combo_boxes[i].SetStringSelection(string) + + # Single value. else: - string = self._choices[self._data.index(self._default)] - - # Set the selection. - self._combo_boxes[i].SetStringSelection(string) + # Translate if needed. + if self._default in self._choices: + string = self._default + elif self._default not in self._data: + string = self._default + else: + string = self._choices[self._data.index(self._default)] + + # Set the selection. + self._combo_boxes[i].SetStringSelection(string) # Restore the selection. else: