mailr16021 - /branches/uf_redesign/gui/misc.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 - 17:54:
Author: bugman
Date: Sun May  6 17:54:29 2012
New Revision: 16021

URL: http://svn.gna.org/viewcvs/relax?rev=16021&view=rev
Log:
Added GUI conversion functions for tuples.


Modified:
    branches/uf_redesign/gui/misc.py

Modified: branches/uf_redesign/gui/misc.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/misc.py?rev=16021&r1=16020&r2=16021&view=diff
==============================================================================
--- branches/uf_redesign/gui/misc.py (original)
+++ branches/uf_redesign/gui/misc.py Sun May  6 17:54:29 2012
@@ -346,6 +346,28 @@
     return val
 
 
+def gui_to_tuple(string):
+    """Convert the GUI obtained string to a tuple.
+
+    @param string:  The list in string form.
+    @type string:   str or unicode
+    @return:        The list.
+    @rtype:         list
+    """
+
+    # No value.
+    if string in ['', u'', None]:
+        return ()
+
+    # Convert.
+    val = eval(string)
+    if not isinstance(val, tuple):
+        val = tuple(val)
+
+    # Return the list.
+    return val
+
+
 def int_to_gui(num):
     """Convert the int into the GUI string.
 
@@ -460,3 +482,20 @@
 
     # Convert.
     return unicode(string)
+
+
+def tuple_to_gui(tuple):
+    """Convert the tuple into the GUI string.
+
+    @param tuple:   The Python tuple.
+    @type tuple:    tuple or None
+    @return:        The GUI string.
+    @rtype:         unicode
+    """
+
+    # No input.
+    if tuple == None:
+        tuple = ''
+
+    # Convert.
+    return unicode(tuple)




Related Messages


Powered by MHonArc, Updated Sun May 06 18:20:01 2012