Author: bugman Date: Fri May 4 16:33:38 2012 New Revision: 15967 URL: http://svn.gna.org/viewcvs/relax?rev=15967&view=rev Log: The List and Combo_list class now have ResetChoices() methods. This allows these elements to fit with the auto-generated GUI user functions. Modified: branches/uf_redesign/gui/components/combo_list.py branches/uf_redesign/gui/wizard_elements.py Modified: branches/uf_redesign/gui/components/combo_list.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/components/combo_list.py?rev=15967&r1=15966&r2=15967&view=diff ============================================================================== --- branches/uf_redesign/gui/components/combo_list.py (original) +++ branches/uf_redesign/gui/components/combo_list.py Fri May 4 16:33:38 2012 @@ -27,6 +27,7 @@ import wx # relax GUI module imports. +from gui.misc import str_to_gui from gui.paths import icon_16x16 @@ -232,3 +233,30 @@ # Return the list. return text + + + def ResetChoices(self, combo_choices=None, combo_data=None, combo_default=None): + """Special wizard method for resetting the list of choices in a ComboBox type element. + + @param key: The key corresponding to the desired GUI element. + @type key: str + @keyword combo_choices: The list of choices to present to the user. This is only used if the element_type is set to 'combo'. + @type combo_choices: list of str + @keyword combo_data: The data returned by a call to GetValue(). This is only used if the element_type is set to 'combo'. If supplied, it should be the same length at the combo_choices list. If not supplied, the combo_choices list will be used for the returned data. + @type combo_data: list + @keyword combo_default: The default value of the ComboBox. This is only used if the element_type is set to 'combo'. + @type combo_default: str or None + """ + + # Loop over the combo boxes. + for i in range(len(self._combo_boxes)): + # First clear all data. + self._combo_boxes[i].Clear() + + # Loop over the choices and data, adding both to the end. + for j in range(len(combo_choices)): + self._combo_boxes[i].Insert(str_to_gui(combo_choices[j]), j, combo_data[j]) + + # Set the default selection. + if combo_default: + self._combo_boxes[i].SetStringSelection(combo_default) Modified: branches/uf_redesign/gui/wizard_elements.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/wizard_elements.py?rev=15967&r1=15966&r2=15967&view=diff ============================================================================== --- branches/uf_redesign/gui/wizard_elements.py (original) +++ branches/uf_redesign/gui/wizard_elements.py Fri May 4 16:33:38 2012 @@ -288,9 +288,10 @@ # Store the args. self.name = name + self.element_type = element_type # Initialise the default element. - if element_type == 'default': + if self.element_type == 'default': # Init. sub_sizer = wx.BoxSizer(wx.HORIZONTAL) @@ -346,12 +347,12 @@ self._field.SetToolTipString(tooltip) # Initialise the combo list input field. - elif element_type == 'combo_list': + elif self.element_type == 'combo_list': self._field = Combo_list(parent, sizer, desc, n=combo_list_size, choices=combo_choices, tooltip=tooltip) # Unknown field. else: - raise RelaxError("Unknown element type '%s'." % element_type) + raise RelaxError("Unknown element type '%s'." % self.element_type) def GetValue(self): @@ -363,6 +364,24 @@ # Convert and return the value. return gui_to_list(self._field.GetValue()) + + + def ResetChoices(self, combo_choices=None, combo_data=None, combo_default=None): + """Special wizard method for resetting the list of choices in a ComboBox type element. + + @param key: The key corresponding to the desired GUI element. + @type key: str + @keyword combo_choices: The list of choices to present to the user. This is only used if the element_type is set to 'combo_list'. + @type combo_choices: list of str + @keyword combo_data: The data returned by a call to GetValue(). This is only used if the element_type is set to 'combo_list'. If supplied, it should be the same length at the combo_choices list. If not supplied, the combo_choices list will be used for the returned data. + @type combo_data: list + @keyword combo_default: The default value of the ComboBox. This is only used if the element_type is set to 'combo_list'. + @type combo_default: str or None + """ + + # The ComboBox list. + if self.element_type == 'combo_list': + self._field.ResetChoices(combo_choices=combo_choices, combo_data=combo_data, combo_default=combo_default) def SetValue(self, value):