def _open_changed(self):
     """Handles the user clicking the 'Open...' button."""
     file_name = open_file(
         extensions=TextInfo(), filter='Python file (*.py)|*.py', id=demo_id
     )
     if file_name != '':
         self.file_name = file_name
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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),
예제 #6
0
 def _open_exdesign_fired(self):
     file_name = open_file(filter=['*.eds'],
                           extensions=[FileInfo(), TextInfo()])
     if file_name != '':
         self.exdesign_spec_file = file_name