def save_study_as(self, ui_info): file_name = save_file(filter=['*.pst'], extensions=[FileInfo(), TextInfo()]) if file_name != '': ui_info.object.save(file_name) ui_info.object.file_path = file_name self._set_title_string(ui_info)
def save_study(self, ui_info): if ui_info.object.file_path == '': file_name = save_file(filter=['*.pst'], extensions=[FileInfo(), TextInfo()]) if file_name == '': return else: file_name = ui_info.object.file_path ui_info.object.save(file_name)
def _load_button_changed(self): f = open_file(file_name=os.getcwd(), extensions=[FileInfo()], filter=['*.nxs', '*.dat']) self.filename = f if f != '': name, ext = os.path.splitext(f) if ext == '.nxs': self.load_and_extract_nexus(f) while self.file_thread.isAlive(): time.sleep(1) self.form_experiment() elif ext == '.dat': self.load_and_extract_dat_file(f)
def open_study(self, ui_info): if ui_info.object.dirty: # discard / save dialog answer = confirm(ui_info.ui.control, 'Study modified. Save it?', title='Open study', cancel=True, default=YES) if answer == YES: self.save_study(ui_info) elif answer == CANCEL: return file_name = open_file(filter=['*.pst'], extensions=[FileInfo(), TextInfo()]) if file_name != '': ui_info.object.load(file_name) ui_info.object.file_path = file_name self._set_title_string(ui_info)
# Issue related to the demo warning: enthought/traitsui#953 from traits.api import HasTraits, File, Button from traitsui.api import View, HGroup, Item from traitsui.file_dialog import open_file, FileInfo, TextInfo, ImageInfo # -- FileDialogDemo Class ------------------------------------------------- # Demo specific file dialig id: demo_id = 'traitsui.demo.standard_editors.file_dialog.multiple_info' # The list of file dialog extensions to use: extensions = [FileInfo(), TextInfo(), ImageInfo()] class FileDialogDemo(HasTraits): # The name of the selected file: file_name = File() # The button used to display the file dialog: open = Button('Open...') # -- Traits View Definitions ---------------------------------------------- traits_view = View( HGroup( Item('open', show_label=False),
def _open_changed(self): """ Handles the user clicking the 'Open...' button. """ file_name = open_file(extensions=FileInfo(), id=demo_id) if file_name != '': self.file_name = file_name
def _open_exdesign_fired(self): file_name = open_file(filter=['*.eds'], extensions=[FileInfo(), TextInfo()]) if file_name != '': self.exdesign_spec_file = file_name