mailr14056 - /branches/gui_testing/gui/misc.py


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

Header


Content

Posted by edward on August 02, 2011 - 11:24:
Author: bugman
Date: Tue Aug  2 11:24:37 2011
New Revision: 14056

URL: http://svn.gna.org/viewcvs/relax?rev=14056&view=rev
Log:
Modified the gui_to_float() and gui_to_int() fns to handle expressions.

This means that the float '1.23 * 1e-6' or '1.234 * 4 - 0.06' can input by 
the user.


Modified:
    branches/gui_testing/gui/misc.py

Modified: branches/gui_testing/gui/misc.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/misc.py?rev=14056&r1=14055&r2=14056&view=diff
==============================================================================
--- branches/gui_testing/gui/misc.py (original)
+++ branches/gui_testing/gui/misc.py Tue Aug  2 11:24:37 2011
@@ -166,7 +166,14 @@
         return None
 
     # Convert.
-    return float(string)
+    val = eval(string)
+
+    # Not a float!
+    if type(val) != float:
+        return string
+
+    # A float.
+    return val
 
 
 def gui_to_int(string):
@@ -183,7 +190,14 @@
         return None
 
     # Convert.
-    return int(string)
+    val = eval(string)
+
+    # Not an int!
+    if type(val) != int:
+        return string
+
+    # An int.
+    return val
 
 
 def float_to_gui(num):




Related Messages


Powered by MHonArc, Updated Tue Aug 02 12:00:02 2011