Author: bugman Date: Fri May 18 11:08:46 2012 New Revision: 16331 URL: http://svn.gna.org/viewcvs/relax?rev=16331&view=rev Log: The Combo_list GUI element now handles the wiz_combo_list_min uf arg arg. If not enough elements are set, Combo_list.GetValue() will return None. This is caught by the auto -generated GUI user functions on_execute() method, preventing the execution of the user function. Modified: branches/uf_redesign/gui/components/combo_list.py branches/uf_redesign/gui/input_elements/sequence.py branches/uf_redesign/gui/input_elements/sequence_2D.py branches/uf_redesign/gui/uf_objects.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=16331&r1=16330&r2=16331&view=diff ============================================================================== --- branches/uf_redesign/gui/components/combo_list.py (original) +++ branches/uf_redesign/gui/components/combo_list.py Fri May 18 11:08:46 2012 @@ -35,7 +35,7 @@ class Combo_list: """The combo list GUI element.""" - def __init__(self, parent, sizer, desc, value_type=None, n=1, choices=None, data=None, default=None, evt_fn=None, tooltip=None, divider=None, padding=0, spacer=None, read_only=True, can_be_none=False): + def __init__(self, parent, sizer, desc, value_type=None, n=1, min_length=None, choices=None, data=None, default=None, evt_fn=None, tooltip=None, divider=None, padding=0, spacer=None, read_only=True, can_be_none=False): """Build the combo box list widget for a list of list selections. @param parent: The parent GUI element. @@ -48,6 +48,8 @@ @type value_type: str @keyword n: The number of initial entries. @type n: int + @keyword min_length: The minimum length for the Combo_list object. + @type min_length: int or None @keyword choices: The list of choices (all combo boxes will have the same list). @type choices: list of str @keyword 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 choices list. If not supplied, the choices list will be used for the returned data. @@ -82,6 +84,7 @@ self._padding = padding self._read_only = read_only self._can_be_none = can_be_none + self._min_length = min_length # The value types. if value_type in ['float', 'num']: @@ -255,6 +258,7 @@ text = u'[' # Loop over the combo boxes. + n = 0 for i in range(len(self._combo_boxes)): # Get the value. val = self.convert_from_gui(self._combo_boxes[i].GetClientData(self._combo_boxes[i].GetSelection())) @@ -270,11 +274,17 @@ # Add the value. text = "%s'%s'" % (text, val) + # Increment the number. + n += 1 + # End. text = "%s]" % text # Return the list. - return text + if self._min_length != None and n < self._min_length: + return None + else: + return text def ResetChoices(self, combo_choices=None, combo_data=None, combo_default=None): Modified: branches/uf_redesign/gui/input_elements/sequence.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/input_elements/sequence.py?rev=16331&r1=16330&r2=16331&view=diff ============================================================================== --- branches/uf_redesign/gui/input_elements/sequence.py (original) +++ branches/uf_redesign/gui/input_elements/sequence.py Fri May 18 11:08:46 2012 @@ -50,7 +50,7 @@ - tuple of strings """ - def __init__(self, name=None, default=None, parent=None, element_type='default', seq_type=None, value_type=None, dim=None, min=0, max=1000, sizer=None, desc=None, combo_choices=None, combo_data=None, combo_list_size=None, tooltip=None, divider=None, padding=0, spacer=None, height_element=27, single_value=False, read_only=False, can_be_none=False): + def __init__(self, name=None, default=None, parent=None, element_type='default', seq_type=None, value_type=None, dim=None, min=0, max=1000, sizer=None, desc=None, combo_choices=None, combo_data=None, combo_list_min=None, tooltip=None, divider=None, padding=0, spacer=None, height_element=27, single_value=False, read_only=False, can_be_none=False): """Set up the element. @keyword name: The name of the element to use in titles, etc. @@ -79,8 +79,8 @@ @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_list_size: The number of initial entries in a Combo_list object. - @type combo_list_size: int or None + @keyword combo_list_min: The minimum length for the Combo_list object. + @type combo_list_min: int or None @keyword tooltip: The tooltip which appears on hovering over the text or input field. @type tooltip: str @keyword divider: The position of the divider. @@ -196,7 +196,7 @@ read_only = False # Set up the Combo_list object. - self._field = Combo_list(parent, sizer, desc, value_type=value_type, n=combo_list_size, choices=combo_choices, data=combo_data, default=default, tooltip=tooltip, read_only=read_only, can_be_none=can_be_none) + self._field = Combo_list(parent, sizer, desc, value_type=value_type, min_length=combo_list_min, choices=combo_choices, data=combo_data, default=default, tooltip=tooltip, read_only=read_only, can_be_none=can_be_none) # Unknown field. else: Modified: branches/uf_redesign/gui/input_elements/sequence_2D.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/input_elements/sequence_2D.py?rev=16331&r1=16330&r2=16331&view=diff ============================================================================== --- branches/uf_redesign/gui/input_elements/sequence_2D.py (original) +++ branches/uf_redesign/gui/input_elements/sequence_2D.py Fri May 18 11:08:46 2012 @@ -48,7 +48,7 @@ - tuple of strings """ - def __init__(self, name=None, default=None, parent=None, sizer=None, element_type='default', seq_type=None, value_type=None, dim=None, min=0, max=1000, titles=None, desc=None, combo_choices=None, combo_data=None, combo_list_size=None, tooltip=None, divider=None, padding=0, spacer=None, height_element=27, read_only=False, can_be_none=False): + def __init__(self, name=None, default=None, parent=None, sizer=None, element_type='default', seq_type=None, value_type=None, dim=None, min=0, max=1000, titles=None, desc=None, combo_choices=None, combo_data=None, combo_list_min=None, tooltip=None, divider=None, padding=0, spacer=None, height_element=27, read_only=False, can_be_none=False): """Set up the element. @keyword name: The name of the element to use in titles, etc. @@ -79,8 +79,8 @@ @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_list_size: The number of initial entries in a Combo_list object. - @type combo_list_size: int or None + @keyword combo_list_min: The minimum length for the Combo_list object. + @type combo_list_min: int or None @keyword tooltip: The tooltip which appears on hovering over the text or input field. @type tooltip: str @keyword divider: The optional position of the divider. If None, the class variable _div_left will be used. @@ -101,7 +101,7 @@ self.titles = titles # Initialise the base class. - Sequence.__init__(self, name=name, default=default, parent=parent, sizer=sizer, element_type=element_type, seq_type=seq_type, value_type=value_type, dim=dim, min=min, max=max, desc=desc, combo_choices=combo_choices, combo_data=combo_data, combo_list_size=combo_list_size, tooltip=tooltip, divider=divider, padding=padding, spacer=spacer, height_element=height_element, read_only=read_only, can_be_none=can_be_none) + Sequence.__init__(self, name=name, default=default, parent=parent, sizer=sizer, element_type=element_type, seq_type=seq_type, value_type=value_type, dim=dim, min=min, max=max, desc=desc, combo_choices=combo_choices, combo_data=combo_data, combo_list_min=combo_list_min, tooltip=tooltip, divider=divider, padding=padding, spacer=spacer, height_element=height_element, read_only=read_only, can_be_none=can_be_none) def open_dialog(self, event): Modified: branches/uf_redesign/gui/uf_objects.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/uf_objects.py?rev=16331&r1=16330&r2=16331&view=diff ============================================================================== --- branches/uf_redesign/gui/uf_objects.py (original) +++ branches/uf_redesign/gui/uf_objects.py Fri May 18 11:08:46 2012 @@ -438,7 +438,7 @@ if isinstance(arg['dim'], int): dim = arg['dim'] - self.uf_args[arg['name']] = Sequence(name=arg['name'], parent=self, default=arg['default'], element_type=arg['wiz_element_type'], seq_type=seq_type, value_type=value_type, dim=dim, min=arg['min'], max=arg['max'], sizer=sizer, desc=desc, combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], combo_list_size=arg['wiz_combo_list_size'], tooltip=arg['desc'], single_value=single_value, divider=self._div_left, height_element=self.height_element, read_only=arg['wiz_read_only'], can_be_none=arg['can_be_none']) + self.uf_args[arg['name']] = Sequence(name=arg['name'], parent=self, default=arg['default'], element_type=arg['wiz_element_type'], seq_type=seq_type, value_type=value_type, dim=dim, min=arg['min'], max=arg['max'], sizer=sizer, desc=desc, combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], combo_list_min=arg['wiz_combo_list_min'], tooltip=arg['desc'], single_value=single_value, divider=self._div_left, height_element=self.height_element, read_only=arg['wiz_read_only'], can_be_none=arg['can_be_none']) # 2D sequence types. elif arg['py_type'] in ['float_list_of_lists', 'int_list_of_lists', 'num_list_of_lists', 'str_list_of_lists', 'float_tuple_of_tuples', 'int_tuple_of_tuples', 'num_tuple_of_tuples', 'str_tuple_of_tuples', 'float_matrix', 'int_matrix']: @@ -456,7 +456,7 @@ else: value_type = 'str' - self.uf_args[arg['name']] = Sequence_2D(name=arg['name'], parent=self, default=arg['default'], sizer=sizer, element_type=arg['wiz_element_type'], seq_type=seq_type, value_type=value_type, dim=arg['dim'], min=arg['min'], max=arg['max'], titles=arg['list_titles'], desc=desc, combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], combo_list_size=arg['wiz_combo_list_size'], tooltip=arg['desc'], divider=self._div_left, height_element=self.height_element, read_only=arg['wiz_read_only'], can_be_none=arg['can_be_none']) + self.uf_args[arg['name']] = Sequence_2D(name=arg['name'], parent=self, default=arg['default'], sizer=sizer, element_type=arg['wiz_element_type'], seq_type=seq_type, value_type=value_type, dim=arg['dim'], min=arg['min'], max=arg['max'], titles=arg['list_titles'], desc=desc, combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], combo_list_min=arg['wiz_combo_list_min'], tooltip=arg['desc'], divider=self._div_left, height_element=self.height_element, read_only=arg['wiz_read_only'], can_be_none=arg['can_be_none']) # Unknown type. else: @@ -621,6 +621,10 @@ # Store the value. kargs[name] = self.GetValue(name) + + # Skip execution when a Combo_list does not have enough elements. + if self.uf_data.kargs[i]['wiz_combo_list_min'] != None and kargs[name] == None: + return # Handle the free file format args. if 'free_file_format' in self.uf_args: