mailr13908 - /branches/gui_testing/gui/user_functions/value.py


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

Header


Content

Posted by edward on July 26, 2011 - 22:17:
Author: bugman
Date: Tue Jul 26 22:17:25 2011
New Revision: 13908

URL: http://svn.gna.org/viewcvs/relax?rev=13908&view=rev
Log:
The value.set user function GUI page now converts values using the new 
data_type() API method.


Modified:
    branches/gui_testing/gui/user_functions/value.py

Modified: branches/gui_testing/gui/user_functions/value.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/value.py?rev=13908&r1=13907&r2=13908&view=diff
==============================================================================
--- branches/gui_testing/gui/user_functions/value.py (original)
+++ branches/gui_testing/gui/user_functions/value.py Tue Jul 26 22:17:25 2011
@@ -28,7 +28,7 @@
 
 # relax module imports.
 from generic_fns import pipes
-from relax_errors import RelaxImplementError, RelaxNoPipeError
+from relax_errors import RelaxError, RelaxImplementError, RelaxNoPipeError
 import specific_fns
 
 # GUI module imports.
@@ -92,6 +92,7 @@
 
         # Get the specific functions.
         data_names = specific_fns.setup.get_specific_fn('data_names', 
cdp.pipe_type, raise_error=False)
+        self.data_type = specific_fns.setup.get_specific_fn('data_type', 
cdp.pipe_type, raise_error=False)
         return_data_desc = 
specific_fns.setup.get_specific_fn('return_data_desc', cdp.pipe_type, 
raise_error=False)
 
         # The data names, if they exist.
@@ -101,7 +102,7 @@
             gui_raise(RelaxImplementError())
 
         # Loop over the parameters.
-        for name in data_names(set='params'):
+        for name in (data_names(set='params') + data_names(set='generic')):
             # Get the description.
             desc = return_data_desc(name)
 
@@ -120,9 +121,16 @@
     def on_execute(self):
         """Execute the user function."""
 
-        # The parameter and value.
+        # The parameter.
         param = self.param.GetClientData(self.param.GetSelection())
-        val = gui_to_str(self.val.GetValue())
+
+        # The value (converted to the correct type).
+        val_str = gui_to_str(self.val.GetValue())
+        val_type = self.data_type(param)
+        try:
+            val = apply(val_type, val_str)
+        except ValueError:
+            gui_raise(RelaxError("The value '%s' should be of the type %s." 
% (val_str, val_type)))
 
         # The spin ID.
         spin_id = gui_to_str(self.spin_id.GetValue())




Related Messages


Powered by MHonArc, Updated Tue Jul 26 22:20:03 2011