Changeset 503cc34 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Jul 20, 2016 12:00:51 PM (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:
- 7c8ddb83
- Parents:
- 91807fc
- Location:
- src/sas/sasgui/perspectives/file_converter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
r3ea9371 r503cc34 56 56 self.data_type = "ascii" 57 57 58 self.metadata = { 59 'title': None, 60 'run': None, 61 'run_name': None, 62 'instrument': None, 63 'detector': [Detector()], 64 'sample': Sample(), 65 'source': Source() 66 } 67 68 self.metadata['detector'][0].name = '' 69 self.metadata['source'].radiation = 'neutron' 58 self.title = None 59 self.run = None 60 self.run_name = None 61 self.instrument = None 62 self.detector = Detector() 63 self.sample = Sample() 64 self.source = Source() 65 self.properties = ['title', 'run', 'run_name', 'instrument'] 66 67 self.detector.name = '' 68 self.source.radiation = 'neutron' 70 69 71 70 self._do_layout() … … 106 105 return 107 106 108 self. metadata['sample'].ID = self.metadata['title']107 self.sample.ID = self.title 109 108 110 109 try: … … 128 127 data.filename = output_path.split('\\')[-1] 129 128 130 if self. metadata['run']is not None:131 run = self. metadata['run']132 run_name = self. metadata['run_name']129 if self.run is not None: 130 run = self.run 131 run_name = self.run_name 133 132 134 133 if not isinstance(run, list) and run is not None: 135 self. metadata['run']= [run]134 self.run = [run] 136 135 else: 137 136 run = run[0] … … 139 138 if not isinstance(run_name, dict): 140 139 if run_name is not None: 141 self. metadata['run_name']= { run: run_name }140 self.run_name = { run: run_name } 142 141 else: 143 self. metadata['run_name']= {}142 self.run_name = {} 144 143 elif run_name != {}: 145 self. metadata['run_name'][run] = run_name.values()[0]144 self.run_name[run] = run_name.values()[0] 146 145 else: 147 self.metadata['run'] = [] 148 self.metadata['run_name'] = {} 149 150 for attr, value in self.metadata.iteritems(): 151 if value is not None: 152 setattr(data, attr, value) 146 self.run = [] 147 self.run_name = {} 148 149 metadata = { 150 'title': self.title, 151 'run': self.run, 152 'run_name': self.run_name, 153 'intrument': self.instrument, 154 'detector': [self.detector], 155 'sample': self.sample, 156 'source': self.source 157 } 158 159 for key, value in metadata.iteritems(): 160 setattr(data, key, value) 153 161 154 162 self.convert_to_cansas(data, output_path) … … 183 191 detector_frame = MetadataWindow(DetectorPanel, 184 192 parent=self.parent.manager.parent, manager=self, 185 metadata=self. metadata['detector'][0], title='Detector Metadata')193 metadata=self.detector, title='Detector Metadata') 186 194 self.meta_frames.append(detector_frame) 187 195 self.parent.manager.put_icon(detector_frame) … … 194 202 sample_frame = MetadataWindow(SamplePanel, 195 203 parent=self.parent.manager.parent, manager=self, 196 metadata=self. metadata['sample'], title='Sample Metadata')204 metadata=self.sample, title='Sample Metadata') 197 205 self.meta_frames.append(sample_frame) 198 206 self.parent.manager.put_icon(sample_frame) … … 205 213 source_frame = MetadataWindow(SourcePanel, 206 214 parent=self.parent.manager.parent, manager=self, 207 metadata=self. metadata['source'], title="Source Metadata")215 metadata=self.source, title="Source Metadata") 208 216 self.meta_frames.append(source_frame) 209 217 self.parent.manager.put_icon(source_frame) … … 224 232 event.Skip() 225 233 rtype = event.GetEventObject().GetValue().lower() 226 self. metadata['source'].radiation = rtype234 self.source.radiation = rtype 227 235 228 236 def metadata_changed(self, event): … … 232 240 value = textbox.GetValue().strip() 233 241 234 if value == '': 235 self.metadata[attr] = None 236 else: 237 self.metadata[attr] = value 242 if value == '': value = None 243 244 setattr(self, attr, value) 238 245 239 246 … … 332 339 333 340 y = 0 334 windows = ['detector', 'sample', 'source'] 335 for item in self.metadata.keys(): 336 # Don't make fields for properties that have their own windows 337 if item in windows: continue 341 for item in self.properties: 338 342 label_txt = item.replace('_', ' ').capitalize() 339 343 label = wx.StaticText(metadata_pane, -1, label_txt, -
src/sas/sasgui/perspectives/file_converter/meta_panels.py
r91807fc r503cc34 92 92 return 93 93 94 self.parent.manager. metadata['detector'] = [self.metadata]94 self.parent.manager.detector = self.metadata 95 95 self.parent.on_close(event) 96 96 … … 194 194 return 195 195 196 self.parent.manager. metadata['sample']= self.metadata196 self.parent.manager.sample = self.metadata 197 197 self.parent.on_close(event) 198 198 … … 305 305 return 306 306 307 self.parent.manager. metadata['source']= self.metadata307 self.parent.manager.source = self.metadata 308 308 self.parent.on_close(event) 309 309
Note: See TracChangeset
for help on using the changeset viewer.