mailr11954 - /branches/bieri_gui/gui_bieri/components/spin_view.py


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

Header


Content

Posted by edward on December 23, 2010 - 11:09:
Author: bugman
Date: Thu Dec 23 11:09:10 2010
New Revision: 11954

URL: http://svn.gna.org/viewcvs/relax?rev=11954&view=rev
Log:
Better presentation of lists and dictionaries in the spin container windows.


Modified:
    branches/bieri_gui/gui_bieri/components/spin_view.py

Modified: branches/bieri_gui/gui_bieri/components/spin_view.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/components/spin_view.py?rev=11954&r1=11953&r2=11954&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/components/spin_view.py (original)
+++ branches/bieri_gui/gui_bieri/components/spin_view.py Thu Dec 23 11:09:10 
2010
@@ -486,8 +486,42 @@
             # The type.
             obj_type = split(str(type(obj)), "'")[1]
 
-            # Add the data to the list.
-            table.Append((name, obj, obj_type))
+            # List types.
+            if obj_type in ['list', 'numpy.ndarray'] and len(obj) > 1:
+                # The first row.
+                table.Append((name, "[%s," % obj[0], obj_type))
+
+                # The rest of the rows.
+                for i in range(1, len(obj)-1):
+                    table.Append(('', " %s," % obj[i], ''))
+
+                # The last row.
+                table.Append(('', " %s]" % obj[-1], ''))
+
+            # Dictionary types.
+            elif obj_type == 'dict':
+                # The keys.
+                keys = obj.keys()
+                keys.sort()
+
+                # Single entry (or None).
+                if len(keys) < 2:
+                    table.Append((name, obj, obj_type))
+                    continue
+
+                # The first row.
+                table.Append((name, "{'%s': %s," % (keys[0], obj[keys[0]]), 
obj_type))
+
+                # The rest of the rows.
+                for i in range(1, len(keys)-1):
+                    table.Append(('', " '%s': %s," % (keys[i], 
obj[keys[i]]), ''))
+
+                # The last row.
+                table.Append(('', " '%s': %s}" % (keys[-1], obj[keys[-1]]), 
''))
+
+            # All other data types.
+            else:
+                table.Append((name, obj, obj_type))
 
         # Add the table to the sizer.
         sizer.Add(table, 1, wx.ALL|wx.EXPAND, 0)




Related Messages


Powered by MHonArc, Updated Thu Dec 23 12:20:02 2010