Changeset c4f6851 in sasview
- Timestamp:
- Mar 5, 2015 5:22:28 PM (10 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- c1c14ba
- Parents:
- b40ad40
- Location:
- src/sas/perspectives
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/calculator/gen_scatter_panel.py
r824e488 rc4f6851 1318 1318 1319 1319 for key in sets.keys(): 1320 exec "omfdata.%s = sets['%s']" % (key, key)1320 setattr(omfdata, key, sets[key]) 1321 1321 1322 1322 omf2sld = sas_gen.OMF2SLD() -
src/sas/perspectives/invariant/invariant_panel.py
r1128bd31 rc4f6851 802 802 for key in comp_state: 803 803 value = comp_state[key] 804 try: 805 exec "self.%s.SetValue(str(%s))" % (key, value) 806 except TypeError: 807 exec "self.%s.SetValue(%s)" % (key, value) 808 except: 809 logging.error(sys.exc_value) 804 self._set_property_value(key, value) 810 805 811 806 self.compute_invariant(event=None) … … 815 810 # set the inputs and boxes 816 811 value = current_state[key] 817 try: 818 exec 'self.%s.SetValue(str(%s))' % (key, value) 819 except TypeError: 820 exec 'self.%s.SetValue(%s)' % (key, value) 821 except: 822 logging.error(sys.exc_value) 812 self._set_property_value(key, value) 823 813 824 814 self._enable_high_q_section(event=None) … … 828 818 self.state.state_num = state_num 829 819 820 def _set_property_value(self, key, value): 821 """ 822 Set a property value 823 :param key: property name 824 :param value: value of the property 825 """ 826 try: 827 attr = getattr(self, key) 828 attr.SetValue(str(value)) 829 except: 830 logging.error("Invariant state: %s", sys.exc_value) 830 831 831 832 def get_bookmark_by_num(self, num=None): … … 850 851 for key in comp_state: 851 852 value = comp_state[key] 852 try: 853 exec "self.%s.SetValue(str(%s))" % (key, value) 854 except TypeError: 855 exec "self.%s.SetValue(%s)" % (key, value) 856 except: 857 logging.error(sys.exc_value) 853 self._set_property_value(key, value) 858 854 859 855 self.compute_invariant(event=None) … … 861 857 for key in current_state: 862 858 value = current_state[key] 863 try: 864 exec 'self.%s.SetValue(str(%s))' % (key, value) 865 except TypeError: 866 exec 'self.%s.SetValue(%s)' % (key, value) 867 except: 868 logging.error(sys.exc_value) 859 self._set_property_value(key, value) 869 860 self.state.saved_state = copy.deepcopy(current_state) 870 861 … … 925 916 if value == None or value.lstrip().rstrip() == '': 926 917 value = 'None' 927 exec 'self.state.%s = %s' % (name, value)928 exec "self.state.saved_state['%s'] = %s" % (name,value)918 setattr(self.state, name, str(value)) 919 self.state.saved_state[name] = str(value) 929 920 930 921 # set the count part of radio button clicked … … 937 928 name = title 938 929 value = False 939 exec "self.state.saved_state['%s'] = %s" % (name,value)930 self.state.saved_state[name] = str(value) 940 931 941 932 # Instead of changing the future, create a new future. … … 1059 1050 logging.error(sys.exc_value) 1060 1051 1061 # Instead of changing the future, create a new future.1062 #max_state_num = len(self.state.state_list)-11063 #self.state.saved_state['state_num'] = max_state_num1064 1065 1052 # try to add new state of the text changes in the state_list 1066 1053 try: 1067 1054 if value.strip() == None: 1068 1055 value = '' 1069 exec "self.state.%s = '%s'" % (name, value)1070 exec "self.state.saved_state['%s'] = '%s'" % (name,value)1071 exec "self.state.input_list['%s'] = '%s'" % (name,value)1056 setattr(self.state, name, str(value)) 1057 self.state.saved_state[name] = str(value) 1058 self.state.input_list[name] = str(value) 1072 1059 if not self.is_power_out: 1073 1060 if name != 'power_low_tcl' and name != 'power_high_tcl': 1074 1061 self.state.saved_state['state_num'] += 1 1075 1062 self.state.state_num = self.state.saved_state['state_num'] 1076 #copy.deepcopy(self.state.saved_state) 1077 self.state.state_list[str(self.state.state_num)] = \ 1078 self.state.clone_state() 1063 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1079 1064 except: 1080 1065 logging.error(sys.exc_value) 1081 1066 1082 #event.Skip()1083 1067 self._set_undo_flag(True) 1084 1068 self._set_redo_flag(False) … … 1098 1082 value = str(obj.GetValue()) 1099 1083 try: 1100 exec "self.state.saved_state['%s'] = '%s'" % (name, value) 1101 self.state.state_list[str(self.state.state_num)] = \ 1102 self.state.clone_state() 1084 self.state.saved_state[name] = str(value) 1085 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1103 1086 except: 1104 1087 logging.error(sys.exc_value) 1105 #if event != None: event.Skip()1106 1088 1107 1089 def _get_input_list(self): -
src/sas/perspectives/pr/inversion_state.py
rb9a5f0e rc4f6851 193 193 for item in in_list: 194 194 element = newdoc.createElement(item[0]) 195 cmd = "element.appendChild(newdoc.createTextNode(str(self.%s)))" 196 exec cmd % item[1] 195 element.appendChild(newdoc.createTextNode(str(getattr(self, item[1])))) 197 196 inputs.appendChild(element) 198 197 … … 203 202 for item in out_list: 204 203 element = newdoc.createElement(item[0]) 205 cmd = "element.appendChild(newdoc.createTextNode(str(self.%s)))" 206 exec cmd % item[1] 204 element.appendChild(newdoc.createTextNode(str(getattr(self, item[1])))) 207 205 outputs.appendChild(element) 208 206 … … 261 259 if input_field is not None: 262 260 try: 263 cmd = 'self.%s = float(input_field.text.strip())' 264 exec cmd % item[1] 261 setattr(self, item[1], float(input_field.text.strip())) 265 262 except: 266 exec 'self.%s = None' % item[1]263 setattr(self, item[1], None) 267 264 input_field = get_content('ns:estimate_bck', entry) 268 265 if input_field is not None: … … 280 277 if input_field is not None: 281 278 try: 282 cmd = 'self.%s = float(input_field.text.strip())' 283 exec cmd % item[1] 279 setattr(self, item[1], float(input_field.text.strip())) 284 280 except: 285 exec 'self.%s = None' % item[1]281 setattr(self, item[1], None) 286 282 287 283 # Look for coefficients
Note: See TracChangeset
for help on using the changeset viewer.