- Timestamp:
- Jul 13, 2016 7:13:41 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:
- 36f4debb
- Parents:
- ff790b3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
rff790b3 rf2b3f28 12 12 from sas.sasgui.guiframe.dataFitting import Data1D 13 13 from sas.sascalc.dataloader.readers.cansas_reader import Reader as CansasReader 14 from sas.sascalc.dataloader.data_info import Detector 14 15 15 16 # Panel size … … 42 43 self.output = None 43 44 45 self.metadata = { 46 'title': None, 47 'run': None, 48 'run_name': None, 49 'instrument': None, 50 'detector': None, 51 } 52 44 53 self._do_layout() 45 54 self.SetAutoLayout(True) … … 85 94 return 86 95 96 output_path = self.output.GetPath() 87 97 data = Data1D(x=qdata, y=iqdata) 88 self.convert_to_cansas(data, self.output.GetPath()) 98 data.filename = output_path.split('\\')[-1] 99 100 if self.metadata['run'] is not None: 101 run = self.metadata['run'] 102 run_name = self.metadata['run_name'] 103 self.metadata['run'] = [run] 104 if run_name is not None: 105 self.metadata['run_name'] = { run: run_name } 106 if self.metadata['detector'] is not None: 107 name = self.metadata['detector'] 108 detector = Detector() 109 detector.name = name 110 self.metadata['detector'] = [detector] 111 112 for attr, value in self.metadata.iteritems(): 113 setattr(data, attr, value) 114 115 self.convert_to_cansas(data, output_path) 89 116 wx.PostEvent(self.parent.manager.parent, 90 117 StatusEvent(status="Conversion completed.")) 91 118 119 def metadata_changed(self, event): 120 event.Skip() 121 textbox = event.GetEventObject() 122 attr = textbox.GetName() 123 value = textbox.GetValue().strip() 124 if value == '': 125 self.metadata[attr] = None 126 else: 127 self.metadata[attr] = value 128 129 92 130 def _do_layout(self): 93 vbox = wx. GridBagSizer(wx.VERTICAL)131 vbox = wx.BoxSizer(wx.VERTICAL) 94 132 95 133 instructions = ("Select the 1 column ASCII files containing the Q Axis" … … 99 137 size=(_STATICBOX_WIDTH+40, -1)) 100 138 instruction_label.Wrap(_STATICBOX_WIDTH+40) 101 vbox.Add(instruction_label, (0,0), (1,1), wx.TOP | wx.LEFT | wx.RIGHT,5)139 vbox.Add(instruction_label, flag=wx.TOP | wx.LEFT | wx.RIGHT, border=5) 102 140 103 141 section = wx.StaticBox(self, -1) … … 139 177 section_sizer.Add(input_grid) 140 178 141 vbox.Add(section_sizer, (1,0), (1,1), wx.ALL, 5) 179 vbox.Add(section_sizer, flag=wx.ALL, border=5) 180 181 metadata_section = wx.CollapsiblePane(self, -1, "Metadata", 182 size=(_STATICBOX_WIDTH+40, -1)) 183 184 metadata_grid = wx.GridBagSizer(5, 5) 185 186 y = 0 187 for item in self.metadata.keys(): 188 label = wx.StaticText(metadata_section.GetPane(), -1, item, 189 style=wx.ALIGN_CENTER_VERTICAL) 190 input_box = wx.TextCtrl(metadata_section.GetPane(), name=item, 191 size=(_STATICBOX_WIDTH-80, -1)) 192 input_box.Bind(wx.EVT_TEXT, self.metadata_changed) 193 metadata_grid.Add(label, (y,0), (1,1), 194 wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) 195 metadata_grid.Add(input_box, (y,1), (1,1), wx.EXPAND) 196 y += 1 197 198 metadata_section.GetPane().SetSizer(metadata_grid) 199 200 vbox.Add(metadata_section, proportion=0, flag=wx.ALL, border=5) 142 201 143 202 vbox.Fit(self)
Note: See TracChangeset
for help on using the changeset viewer.