mailr16327 - in /branches/uf_redesign/gui: components/combo_list.py input_elements/sequence.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on May 18, 2012 - 10:32:
Author: bugman
Date: Fri May 18 10:32:48 2012
New Revision: 16327

URL: http://svn.gna.org/viewcvs/relax?rev=16327&view=rev
Log:
Individual elements of the Sequence and Combo_list GUI element can now be set 
via the SetValue() method.

The Sequence.SetValue() method now accepts the index arg, and this is passed 
onto the
Combo_list.SetValue() method.  The individual elements of the Sequence 
element still cannot be set
via the index.


Modified:
    branches/uf_redesign/gui/components/combo_list.py
    branches/uf_redesign/gui/input_elements/sequence.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=16327&r1=16326&r2=16327&view=diff
==============================================================================
--- branches/uf_redesign/gui/components/combo_list.py (original)
+++ branches/uf_redesign/gui/components/combo_list.py Fri May 18 10:32:48 2012
@@ -327,21 +327,22 @@
                 self._combo_boxes[i].SetStringSelection(string)
 
 
-    def SetValue(self, value):
+    def SetValue(self, value=None, index=None):
         """Special method for setting the value of the GUI element.
 
-        @param value:   The value to set.
-        @type value:    list of str or None
-        """
-
-        # No value.
-        if values == None:
-            return
-
-        # Loop over the combo boxes.
-        for i in range(len(self._combo_boxes)):
-            # Loop until the proper client data is found.
-            for j in range(self._combo_boxes[i].GetCount()):
-                if self._combo_boxes[i].GetClientData(j) == value:
-                    self._combo_boxes[i].SetSelection(j)
-                    break
+        @keyword value: The value to set.
+        @type value:    anything
+        @keyword index: The index of the value to set.
+        @type index:    int
+        """
+
+        # Add elements as needed.
+        if len(self._combo_boxes) <= index:
+            for i in range(len(self._combo_boxes) - index + 1):
+                self._add(None)
+
+        # Loop until the proper client data is found.
+        for j in range(self._combo_boxes[index].GetCount()):
+            if self._combo_boxes[index].GetClientData(j) == value:
+                self._combo_boxes[index].SetSelection(j)
+                break

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=16327&r1=16326&r2=16327&view=diff
==============================================================================
--- branches/uf_redesign/gui/input_elements/sequence.py (original)
+++ branches/uf_redesign/gui/input_elements/sequence.py Fri May 18 10:32:48 
2012
@@ -263,19 +263,27 @@
             self._field.ResetChoices(combo_choices=combo_choices, 
combo_data=combo_data, combo_default=combo_default)
 
 
-    def SetValue(self, value):
+    def SetValue(self, value=None, index=None):
         """Special method for setting the value of the GUI element.
 
-        @param value:   The value to set.
-        @type value:    list of str
-        """
-
-        # Handle single values.
-        if self.single_value and len(value) == 1:
-            value = value[0]
-
-        # Convert and set the value.
-        self._field.SetValue(self.convert_to_gui(value))
+        @keyword value: The value to set.
+        @type value:    value or list of values
+        @keyword index: The index of the value to set, if the full list is 
not given.
+        @type index:    int or None
+        """
+
+        # The ComboBox list.
+        if self.element_type == 'combo_list':
+            self._field.SetValue(value=value, index=index)
+
+        # The other elements.
+        else:
+            # Handle single values.
+            if self.single_value and len(value) == 1:
+                value = value[0]
+
+            # Convert and set the value.
+            self._field.SetValue(self.convert_to_gui(value))
 
 
     def open_dialog(self, event):




Related Messages


Powered by MHonArc, Updated Fri May 18 10:40:01 2012