Changeset 0e11ec7 in sasview for src/sas/sasgui/perspectives/file_converter/converter_widgets.py
- Timestamp:
- Aug 9, 2016 7: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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.