Changeset 9318c4e in sasview
- Timestamp:
- Jul 19, 2016 4:48:06 AM (8 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 3a9801f
- Parents:
- 1aad14e
- Location:
- src/sas/sasgui/perspectives/file_converter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
r2a7722b r9318c4e 50 50 self.iq_input = None 51 51 self.output = None 52 self.to_validate = []53 52 54 53 self.metadata = { … … 60 59 'sample': Sample() 61 60 } 62 self.vectors = ['offset', 'orientation', 'pixel_size', 'beam_center']63 for vector_name in self.vectors:64 setattr(self.metadata['detector'][0], vector_name, Vector())65 61 66 62 self._do_layout() … … 128 124 else: 129 125 self.metadata['run_name'] = {} 130 el se:126 elif run_name != {}: 131 127 self.metadata['run_name'][run] = run_name.values()[0] 132 128 else: 133 129 self.metadata['run'] = [] 134 130 self.metadata['run_name'] = {} 135 if self.metadata['detector'][0].name is None:136 self.metadata['detector'][0].name = ''137 138 # Convert vectors from strings to float139 for vector_name in self.vectors:140 # Vector of strings or Nones141 vector = getattr(self.metadata['detector'][0], vector_name)142 for direction in ['x', 'y', 'z']:143 value = getattr(vector, direction)144 if value is not None:145 value = float(value)146 setattr(vector, direction, value)147 setattr(self.metadata['detector'][0], vector_name, vector)148 131 149 132 for attr, value in self.metadata.iteritems(): … … 168 151 return 169 152 170 for ctrl in self.to_validate:171 ctrl_valid = True172 invalid_control = None173 if isinstance(ctrl, VectorInput):174 ctrl_valid, invalid_control = ctrl.Validate()175 else:176 if ctrl.GetValue() == '': continue177 ctrl_valid = check_float(ctrl)178 invalid_control = ctrl179 if not ctrl_valid:180 msg = "{} must be a valid float".format(181 invalid_control.GetName().replace('_', ' '))182 wx.PostEvent(self.parent.manager.parent,183 StatusEvent(status=msg, info='error'))184 return False185 186 153 return True 187 154 … … 214 181 value = textbox.GetValue().strip() 215 182 216 if attr.startswith('detector_'):217 attr = attr[9:] # Strip detector_218 is_vector = False219 for vector_name in self.vectors:220 if attr.startswith(vector_name): is_vector = True221 if is_vector:222 if value == '': value = None223 direction = attr[-1]224 attr = attr[:-2]225 vector = getattr(self.metadata['detector'][0], attr)226 setattr(vector, direction, value)227 value = vector228 setattr(self.metadata['detector'][0], attr, value)229 return230 231 183 if value == '': 232 184 self.metadata[attr] = None … … 294 246 y = 0 295 247 for item in self.metadata.keys(): 296 if item == 'detector' : continue248 if item == 'detector' or item == 'sample': continue 297 249 label_txt = item.replace('_', ' ').capitalize() 298 250 label = wx.StaticText(metadata_pane, -1, label_txt, -
src/sas/sasgui/perspectives/file_converter/meta_panels.py
r1aad14e r9318c4e 39 39 value = '' 40 40 is_float = False 41 if isinstance(value, list): 42 value = value[0] 41 43 value = str(value) 42 44 if is_float and not '.' in value: value += '.0'
Note: See TracChangeset
for help on using the changeset viewer.