mailr16024 - in /branches/uf_redesign/gui: components/combo_list.py wizard_elements.py


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

Header


Content

Posted by edward on May 06, 2012 - 19:01:
Author: bugman
Date: Sun May  6 19:01:30 2012
New Revision: 16024

URL: http://svn.gna.org/viewcvs/relax?rev=16024&view=rev
Log:
Fix for the Combo_list GUI element - all of the combo boxes are now properly 
updated with values and data.


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=16024&r1=16023&r2=16024&view=diff
==============================================================================
--- branches/uf_redesign/gui/components/combo_list.py (original)
+++ branches/uf_redesign/gui/components/combo_list.py Sun May  6 19:01:30 2012
@@ -34,7 +34,7 @@
 class Combo_list:
     """The combo list GUI element."""
 
-    def __init__(self, parent, sizer, desc, n=1, choices=[], evt_fn=None, 
tooltip=None, divider=None, padding=0, spacer=None, read_only=True):
+    def __init__(self, parent, sizer, desc, n=1, choices=None, data=None, 
default=None, evt_fn=None, tooltip=None, divider=None, padding=0, 
spacer=None, read_only=True):
         """Build the combo box list widget for a list of list selections.
 
         @param parent:      The parent GUI element.
@@ -47,6 +47,10 @@
         @type n:            int
         @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.
+        @type data:         list
+        @keyword default:   The default value of the ComboBox.  This is only 
used if the element_type is set to 'combo'.
+        @type default:      str or None
         @keyword evt_fn:    The event handling function.
         @type evt_fn:       func
         @keyword tooltip:   The tooltip which appears on hovering over the 
text or input field.
@@ -66,6 +70,8 @@
         self._sizer = sizer
         self._desc = desc
         self._choices = choices
+        self._data = data
+        self._default = default
         self._evt_fn = evt_fn
         self._tooltip = tooltip
         self._padding = padding
@@ -144,10 +150,21 @@
         style = wx.CB_DROPDOWN
         if self._read_only:
             style = style | wx.CB_READONLY
-        combo = wx.ComboBox(self._parent, -1, value='', style=style, 
choices=self._choices)
+        combo = wx.ComboBox(self._parent, -1, value='', style=style)
         combo.SetMinSize((50, 27))
         sub_sizer.Add(combo, 1, wx.ALIGN_CENTER_VERTICAL, 0)
         self._combo_boxes.append(combo)
+
+        # Choices.
+        if self._choices != None:
+            print "in"
+            # Loop over the choices and data, adding both to the end.
+            for j in range(len(self._choices)):
+                self._combo_boxes[-1].Insert(str_to_gui(self._choices[j]), 
j, self._data[j])
+
+            # Set the default selection.
+            if self._default:
+                self._combo_boxes[-1].SetStringSelection(self._default)
 
         # The add button.
         if index == 0:
@@ -252,6 +269,11 @@
         @type combo_default:    str or None
         """
 
+        # Store the values.
+        self._choices = combo_choices
+        self._data = combo_data
+        self._default = combo_default
+
         # Loop over the combo boxes.
         for i in range(len(self._combo_boxes)):
             # First clear all data.

Modified: branches/uf_redesign/gui/wizard_elements.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/wizard_elements.py?rev=16024&r1=16023&r2=16024&view=diff
==============================================================================
--- branches/uf_redesign/gui/wizard_elements.py (original)
+++ branches/uf_redesign/gui/wizard_elements.py Sun May  6 19:01:30 2012
@@ -177,7 +177,7 @@
                 read_only = False
 
             # Set up the Combo_list object.
-            self._field = Combo_list(parent, sizer, desc, n=combo_list_size, 
choices=combo_choices, tooltip=tooltip, read_only=read_only)
+            self._field = Combo_list(parent, sizer, desc, n=combo_list_size, 
choices=combo_choices, data=combo_data, default=combo_default, 
tooltip=tooltip, read_only=read_only)
 
         # Unknown field.
         else:




Related Messages


Powered by MHonArc, Updated Sun May 06 19:20:02 2012