mailr13668 - /branches/gui_testing/gui/components/spectrum.py


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

Header


Content

Posted by edward on July 18, 2011 - 09:59:
Author: bugman
Date: Mon Jul 18 09:59:48 2011
New Revision: 13668

URL: http://svn.gna.org/viewcvs/relax?rev=13668&view=rev
Log:
The NOE spectrum type is now shown in the Spectrum_list grid element.


Modified:
    branches/gui_testing/gui/components/spectrum.py

Modified: branches/gui_testing/gui/components/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/components/spectrum.py?rev=13668&r1=13667&r2=13668&view=diff
==============================================================================
--- branches/gui_testing/gui/components/spectrum.py (original)
+++ branches/gui_testing/gui/components/spectrum.py Mon Jul 18 09:59:48 2011
@@ -168,18 +168,67 @@
         # The expandable column width.
         width = x - self.col_label_width - 20
 
+        # Number of columns.
+        n = self.grid.GetNumberCols()
+
+        # Set to equal sizes.
+        width = int(width / n)
+
         # Set the column sizes.
-        self.grid.SetColSize(0, width)
+        for i in range(n):
+            self.grid.SetColSize(i, width)
 
         # Continue with the normal resizing.
         event.Skip()
 
 
+    def noe_spectrum_type(self, index):
+        """Add the NOE spectral type info to the grid.
+
+        @param index:   The column index for the data.
+        @type index:    int
+        @return:        True if a spectrum type exists, False otherwise.
+        @rtype:         bool
+        """
+
+        # No type info.
+        if not hasattr(cdp, 'spectrum_type'):
+            return False
+
+        # Append a column.
+        self.grid.AppendCols(numCols=1)
+
+        # Set the column heading.
+        self.grid.SetColLabelValue(index, "NOE spectrum type")
+
+        # Translation table.
+        table = {
+            'sat': 'Saturated',
+            'ref': 'Reference'
+        }
+
+        # Set the values.
+        flag = False
+        for i in range(len(cdp.spectrum_ids)):
+            # No value.
+            if cdp.spectrum_ids[i] not in cdp.spectrum_type.keys():
+                continue
+
+            # Set the value.
+            self.grid.SetCellValue(i, index, 
table[cdp.spectrum_type[cdp.spectrum_ids[i]]])
+
+            # Flip the flag.
+            flag = True
+
+
     def update(self):
         """Update the spectra listing."""
 
         # First freeze the grid, so that the GUI element doesn't update 
until the end.
         self.grid.Freeze()
+
+        # Initialise the column index for the data.
+        index = 1
 
         # Delete the rows and columns (leaving one row and column).
         self.grid.DeleteRows(numRows=self.grid.GetNumberRows()-1)
@@ -200,6 +249,10 @@
         # Set the headers.
         self.grid.SetColLabelValue(0, "Spectrum ID string")
 
+        # The NOE spectrum type.
+        if self.noe_spectrum_type(index):
+            index += 1
+
         # Set the grid properties once finalised.
         for i in range(self.grid.GetNumberRows()):
             # Row properties.




Related Messages


Powered by MHonArc, Updated Mon Jul 18 10:20:01 2011