Changeset 1aad14e in sasview for src/sas/sasgui/perspectives/file_converter
- Timestamp:
- Jul 19, 2016 5:52:19 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:
- 9318c4e
- Parents:
- 2a7722b
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/19/16 05:13:34)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/19/16 05:52:19)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/meta_panels.py
r2a7722b r1aad14e 34 34 self.metadata = metadata 35 35 36 def get_property_string(self, name, is_float=False): 37 value = getattr(self.metadata, name) 38 if value is None or value == []: 39 value = '' 40 is_float = False 41 value = str(value) 42 if is_float and not '.' in value: value += '.0' 43 return value 44 36 45 def on_change(self, event): 37 46 ctrl = event.GetEventObject() 38 47 value = ctrl.GetValue() 48 name = ctrl.GetName() 49 old_value = getattr(self.metadata, name) 39 50 if value == '': value = None 40 setattr(self.metadata, ctrl.GetName(), value) 51 if isinstance(old_value, list): value = [value] 52 53 setattr(self.metadata, name, value) 41 54 42 55 def on_close(self, event=None): … … 49 62 wx.PostEvent(self.parent.manager.parent.manager.parent, 50 63 StatusEvent(status=msg, info='error')) 51 return 64 return False 52 65 for vector_in in self._vectors: 53 66 is_valid, invalid_ctrl = vector_in.Validate() … … 57 70 wx.PostEvent(self.parent.manager.parent.manager.parent, 58 71 StatusEvent(status=msg, info='error')) 59 return 72 return False 60 73 setattr(self.metadata, vector_in.GetName(), vector_in.GetValue()) 74 return True 61 75 62 76 class DetectorPanel(MetadataPanel): … … 73 87 74 88 def on_close(self, event=None): 75 MetadataPanel.on_close(self, event) 89 if not MetadataPanel.on_close(self, event): 90 return 76 91 77 92 self.parent.manager.metadata['detector'] = [self.metadata] … … 150 165 151 166 name_input.SetValue(self.metadata.name) 152 distance = self.metadata.distance 153 if distance is None: distance = '' 154 elif '.' not in distance: distance += '.0' 155 distance_input.SetValue(str(distance)) 167 distance = self.get_property_string("distance", is_float=True) 168 distance_input.SetValue(distance) 156 169 offset_input.SetValue(self.metadata.offset) 157 170 orientation_input.SetValue(self.metadata.orientation) 158 171 pixel_input.SetValue(self.metadata.pixel_size) 159 172 beam_input.SetValue(self.metadata.beam_center) 160 slit_len = self.metadata.slit_length 161 if slit_len is None: slit_len = '' 162 elif '.' not in slit_len: slit_len += '.0' 173 slit_len = self.get_property_string("slit_length", is_float=True) 163 174 slit_input.SetValue(slit_len) 164 175 … … 170 181 def __init__(self, parent, sample, base=None, *args, **kwargs): 171 182 MetadataPanel.__init__(self, parent, sample, base, *args, **kwargs) 183 if sample.name is None: 184 sample.name = '' 172 185 173 186 self._do_layout() … … 176 189 177 190 def on_close(self, event=None): 178 MetadataPanel.on_close(self, event) 191 if not MetadataPanel.on_close(self, event): 192 return 179 193 180 194 self.parent.manager.metadata['sample'] = self.metadata … … 213 227 y += 1 214 228 229 transmission_label = wx.StaticText(self, -1, "Transmission: ") 230 input_grid.Add(transmission_label, (y,0), (1,1), wx.ALL, 5) 231 transmission_input = wx.TextCtrl(self, -1, name="transmission") 232 input_grid.Add(transmission_input, (y,1), (1,1)) 233 transmission_input.Bind(wx.EVT_TEXT, self.on_change) 234 self._to_validate.append(transmission_input) 235 y += 1 236 237 temperature_label = wx.StaticText(self, -1, "Temperature: ") 238 input_grid.Add(temperature_label, (y,0), (1,1), wx.ALL, 5) 239 temperature_input = wx.TextCtrl(self, -1, name="temperature") 240 temperature_input.Bind(wx.EVT_TEXT, self.on_change) 241 self._to_validate.append(temperature_input) 242 input_grid.Add(temperature_input, (y,1), (1,1)) 243 temp_unit_label = wx.StaticText(self, -1, "Unit: ") 244 input_grid.Add(temp_unit_label, (y,2), (1,1)) 245 temp_unit_input = wx.TextCtrl(self, -1, name="temperature_unit", 246 size=(50,-1)) 247 temp_unit_input.Bind(wx.EVT_TEXT, self.on_change) 248 input_grid.Add(temp_unit_input, (y,3), (1,1)) 249 y += 1 250 251 position_label = wx.StaticText(self, -1, "Position (mm): ") 252 input_grid.Add(position_label, (y,0), (1,1), wx.ALL, 5) 253 position_input = VectorInput(self, "position") 254 self._vectors.append(position_input) 255 input_grid.Add(position_input.GetSizer(), (y,1), (1,2)) 256 y += 1 257 258 orientation_label = wx.StaticText(self, -1, "Orientation (\xb0): ") 259 input_grid.Add(orientation_label, (y,0), (1,1), wx.ALL, 5) 260 orientation_input = VectorInput(self, "orientation", 261 labels=["Roll: ", "Pitch: ", "Yaw: "], z_enabled=True) 262 self._vectors.append(orientation_input) 263 input_grid.Add(orientation_input.GetSizer(), (y,1), (1,3)) 264 y += 1 265 266 details_label = wx.StaticText(self, -1, "Details: ") 267 input_grid.Add(details_label, (y,0), (1,1), wx.ALL, 5) 268 details_input = wx.TextCtrl(self, -1, name="details", 269 style=wx.TE_MULTILINE) 270 input_grid.Add(details_input, (y,1), (3,3), wx.EXPAND) 271 y += 3 272 215 273 name_input.SetValue(self.metadata.name) 216 id_input.SetValue(self.metadata.ID) 217 thickness = self.metadata.thickness 218 if thickness is None: 219 thickness = '' 220 thickness_input.SetValue(str(thickness)) 274 id_input.SetValue(self.get_property_string("ID")) 275 thickness_input.SetValue( 276 self.get_property_string("thickness", is_float=True)) 277 transmission_input.SetValue( 278 self.get_property_string("transmission", is_float=True)) 279 temperature_input.SetValue( 280 self.get_property_string("temperature", is_float=True)) 281 temp_unit_input.SetValue(self.get_property_string("temperature_unit")) 282 position_input.SetValue(self.metadata.position) 283 orientation_input.SetValue(self.metadata.orientation) 284 details_input.SetValue(self.get_property_string("details")) 285 details_input.Bind(wx.EVT_TEXT, self.on_change) 221 286 222 287 done_btn = wx.Button(self, -1, "Done")
Note: See TracChangeset
for help on using the changeset viewer.