Author: bugman Date: Wed Jul 27 09:16:07 2011 New Revision: 13917 URL: http://svn.gna.org/viewcvs/relax?rev=13917&view=rev Log: Expressions can now be used in the value.set GUI user function for the number types. 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=13917&r1=13916&r2=13917&view=diff ============================================================================== --- branches/gui_testing/gui/user_functions/value.py (original) +++ branches/gui_testing/gui/user_functions/value.py Wed Jul 27 09:16:07 2011 @@ -127,10 +127,19 @@ # The value (converted to the correct type). val_str = gui_to_str(self.val.GetValue()) val_type = self.data_type(param) + + # Evaluate numbers. + if val_type in [float, int]: + fn = eval + else: + fn = val_type + + # Convert. try: - val = val_type(val_str) - except ValueError: - gui_raise(RelaxError("The value '%s' should be of the type %s." % (val_str, val_type))) + val = fn(val_str) + except (ValueError, NameError): + gui_raise(RelaxError("The value '%s' should be of the type %s." % (val_str, val_type)), raise_flag=False) + return # The spin ID. spin_id = gui_to_str(self.spin_id.GetValue())