示例#1
0
 def _open_changed(self):
     """Handles the user clicking the 'Open...' button."""
     file_name = open_file(extensions=ImageInfo(),
                           filter=filters,
                           id=demo_id)
     if file_name != '':
         self.file_name = file_name
# 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),