Changeset 0e11ec7 in sasview
- Timestamp:
- Aug 9, 2016 5:23:01 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:
- 94667e27
- Parents:
- dc8a553
- Location:
- src/sas/sasgui/perspectives/file_converter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/file_converter/converter_panel.py
r9c500ab r0e11ec7 10 10 from sas.sasgui.guiframe.panel_base import PanelBase 11 11 from sas.sasgui.perspectives.calculator import calculator_widgets as widget 12 from sas.sasgui.perspectives.file_converter.converter_widgets import VectorInput12 from sas.sasgui.perspectives.file_converter.converter_widgets import FileInput 13 13 from sas.sasgui.perspectives.file_converter.meta_panels import MetadataWindow 14 14 from sas.sasgui.perspectives.file_converter.meta_panels import DetectorPanel … … 486 486 self.on_collapsible_pane(None) 487 487 self.metadata_section.Disable() 488 self.output.SetWildcard("Red2D (*.dat)|*.dat") 488 489 else: 489 490 self.q_input.Enable() 490 491 self.radiation_input.Enable() 491 492 self.metadata_section.Enable() 493 self.output.SetWildcard("CanSAS 1D (*.xml)|*.xml") 492 494 493 495 def radiationtype_changed(self, event): … … 575 577 input_grid.Add(output_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) 576 578 577 self.output = wx.FilePickerCtrl(self, -1, 578 size=(_STATICBOX_WIDTH-80, -1), 579 message="Chose where to save the output file.", 580 style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL, 581 wildcard="CanSAS 1D (*.xml)|*.xml|Red2D (*.dat)|*.dat") 582 input_grid.Add(self.output, (y,1), (1,1), wx.ALL, 5) 579 self.output = FileInput(self, 580 wildcard="CanSAS 1D (*.xml)|*.xml") 581 input_grid.Add(self.output.GetCtrl(), (y,1), (1,1), wx.EXPAND | wx.ALL, 5) 583 582 y += 1 584 583 -
src/sas/sasgui/perspectives/file_converter/converter_widgets.py
rba65aff r0e11ec7 3 3 """ 4 4 import wx 5 import os 5 6 from sas.sascalc.dataloader.data_info import Vector 6 7 from sas.sasgui.guiframe.utils import check_float … … 128 129 self._inputs['z'] = z_input 129 130 z_input.Bind(wx.EVT_TEXT, self._callback) 131 132 class FileInput(object): 133 134 def __init__(self, parent, wildcard=''): 135 self.parent = parent 136 self._sizer = None 137 self._text_ctrl = None 138 self._button_ctrl = None 139 self._filepath = '' 140 self._wildcard = wildcard 141 142 self._do_layout() 143 144 def GetCtrl(self): 145 return self._sizer 146 147 def GetPath(self): 148 return self._filepath 149 150 def SetWildcard(self, wildcard): 151 self._wildcard = wildcard 152 153 154 def _on_text_change(self, event): 155 event.Skip() 156 self._filepath = self._text_ctrl.GetValue() 157 158 def _on_browse(self, event): 159 event.Skip() 160 initial_path = self._filepath 161 initial_dir = os.getcwd() 162 if not os.path.isfile(initial_path): 163 initial_path = '' 164 else: 165 initial_dir = os.path.split(initial_path)[0] 166 167 file_dlg = wx.FileDialog(self.parent, defaultDir=initial_dir, 168 defaultFile=initial_path, wildcard=self._wildcard, 169 style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) 170 if file_dlg.ShowModal() == wx.ID_CANCEL: 171 file_dlg.Destroy() 172 return 173 self._filepath = file_dlg.GetPath() 174 file_dlg.Destroy() 175 self._text_ctrl.SetValue(self._filepath) 176 177 def _do_layout(self): 178 self._sizer = wx.BoxSizer(wx.HORIZONTAL) 179 180 self._text_ctrl = wx.TextCtrl(self.parent, -1) 181 self._sizer.Add(self._text_ctrl, wx.EXPAND) 182 self._text_ctrl.Bind(wx.EVT_TEXT, self._on_text_change) 183 184 self._sizer.AddSpacer(5) 185 186 self._button_ctrl = wx.Button(self.parent, -1, "Browse") 187 self._sizer.Add(self._button_ctrl) 188 self._button_ctrl.Bind(wx.EVT_BUTTON, self._on_browse)
Note: See TracChangeset
for help on using the changeset viewer.