mailr23551 - in /trunk/gui/input_elements: sequence.py sequence_2D.py


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

Header


Content

Posted by edward on May 28, 2014 - 18:11:
Author: bugman
Date: Wed May 28 18:11:40 2014
New Revision: 23551

URL: http://svn.gna.org/viewcvs/relax?rev=23551&view=rev
Log:
Fix for bug #22102, the point argument of the dx.map user function failing in 
the GUI.

This is reported at https://gna.org/bugs/?22102.

The Sequence_2D GUI element used for all list of lists arguments in the user 
function GUI windows
now correctly handles variable length lists.  The first column which shows a 
count of the elements
is now properly taken into account in the SetValue(), GetValue() and 
add_item() methods, via a new
self.offset variable.  The self.variable_length variable has also been fixed 
so it is not
overwritten by the parent Sequence GUI element.


Modified:
    trunk/gui/input_elements/sequence.py
    trunk/gui/input_elements/sequence_2D.py

Modified: trunk/gui/input_elements/sequence.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/gui/input_elements/sequence.py?rev=23551&r1=23550&r2=23551&view=diff
==============================================================================
--- trunk/gui/input_elements/sequence.py        (original)
+++ trunk/gui/input_elements/sequence.py        Wed May 28 18:11:40 2014
@@ -480,9 +480,12 @@
             raise RelaxError("Unknown base data type '%s'." % value_type)
 
         # Variable length.
-        self.variable_length = False
-        if dim == None:
-            self.variable_length = True
+        if not hasattr(self, 'variable_length'):
+            self.variable_length = False
+            self.offset = 0
+            if dim == None:
+                self.variable_length = True
+                self.offset = 1
 
         # The title of the dialog.
         title = "Edit the %s values." % name

Modified: trunk/gui/input_elements/sequence_2D.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/gui/input_elements/sequence_2D.py?rev=23551&r1=23550&r2=23551&view=diff
==============================================================================
--- trunk/gui/input_elements/sequence_2D.py     (original)
+++ trunk/gui/input_elements/sequence_2D.py     Wed May 28 18:11:40 2014
@@ -29,6 +29,7 @@
 
 # relax module imports.
 from gui.input_elements.sequence import Sequence, Sequence_list_ctrl, 
Sequence_window
+from gui.string_conv import int_to_gui
 from lib.check_types import is_list_of_lists
 from status import Status; status = Status()
 
@@ -163,8 +164,10 @@
 
         # Variable length.
         self.variable_length = False
+        self.offset = 0
         if dim[0] == None:
             self.variable_length = True
+            self.offset = 1
 
         # Initialise the base class.
         Sequence_window.__init__(self, name=name, seq_type=seq_type, 
value_type=value_type, dim=dim)
@@ -188,7 +191,7 @@
             # Loop over the items.
             for j in range(self.dim[1]):
                 # The item.
-                item = self.sequence.GetItem(i, j)
+                item = self.sequence.GetItem(i, j+self.offset)
 
                 # Append the value.
                 try:
@@ -238,18 +241,14 @@
 
         # Loop over the entries.
         for i in range(len(values)):
-            # Fixed dimension sequences - set the first value of the 
pre-created list.
-            if self.dim[0] != None:
-                self.sequence.SetStringItem(index=i, col=0, 
label=self.convert_to_gui(values[i][0]))
-
-            # Variable dimension sequences - append the first value to the 
end of the blank list.
-            else:
-                self.sequence.InsertStringItem(sys.maxint, 
self.convert_to_gui(values[i][0]))
+            # Append a row for variable dimension sequences (the first 
element already exists).
+            if self.variable_length and i != 0:
+                self.sequence.InsertStringItem(i, int_to_gui(i+1))
 
             # Loop over the values.
-            for j in range(1, self.dim[1]):
+            for j in range(self.dim[1]):
                 # Set the value.
-                self.sequence.SetStringItem(i, j, 
self.convert_to_gui(values[i][j]))
+                self.sequence.SetStringItem(i, j+self.offset, 
self.convert_to_gui(values[i][j]))
 
         # Refresh.
         self.Refresh()
@@ -268,10 +267,17 @@
         # Set the column title.
         title = "%s%s" % (self.name[0].upper(), self.name[1:])
 
+        # Add a column for the indices.
+        index_width = 0
+        if self.variable_length:
+            index_width = 50
+            self.sequence.InsertColumn(0, "Number")
+            self.sequence.SetColumnWidth(0, index_width)
+
         # Add the columns.
         for i in range(self.dim[1]):
-            self.sequence.InsertColumn(i, self.titles[i])
-            self.sequence.SetColumnWidth(i, self.width/self.dim[1])
+            self.sequence.InsertColumn(i+self.offset, self.titles[i])
+            self.sequence.SetColumnWidth(i+self.offset, (self.width - 
index_width)/self.dim[1])
 
         # Add the table to the sizer.
         sizer.Add(self.sequence, 1, wx.ALL|wx.EXPAND, 0)




Related Messages


Powered by MHonArc, Updated Wed May 28 18:20:02 2014