当前位置: 首页>>代码示例>>Python>>正文


Python api.FileDialog类代码示例

本文整理汇总了Python中pyface.api.FileDialog的典型用法代码示例。如果您正苦于以下问题:Python FileDialog类的具体用法?Python FileDialog怎么用?Python FileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: perform

 def perform(self,event):
     """Perform the Save Phantom  Action """
     wildcard = 'MagicalPhantom files (*.mp)|*.mp|' + FileDialog.WILDCARD_ALL
     parent = self.window.control
     dialog = FileDialog(parent=parent,
                         title = 'Open MagicalPhantom file',
                         action = 'open',wildcard = wildcard)
     if dialog.open()==OK:
         if not isfile(dialog.path):
             error("File '%s' does not exist"%dialog.path,parent)
             return
    
     run_manager = self.window.application.get_service('mphantom.api.RunManager')
     
     phantom = run_manager.model
     
    
     
     print dialog.path
             
     phantom.clear_phantom()
     phantom.load_phantom(dialog.path)
     
    
     
     self.window.active_perspective = self.window.perspectives[1]
开发者ID:zoulianmp,项目名称:mftm,代码行数:26,代码来源:mphantom_actions.py

示例2: _file_dialog_

    def _file_dialog_(self, action, **kw):
        '''
        '''
#         print 'file_dialog', kw
        dlg = FileDialog(action=action, **kw)
        if dlg.open() == OK:
            return dlg.path
开发者ID:jirhiker,项目名称:pychron,代码行数:7,代码来源:manager.py

示例3: save_config_file

 def save_config_file(self, ui_info):
     dialog = FileDialog(action="save as", default_filename="config.ini")
     dialog.open()
     if dialog.return_code == OK:
         save_config(self.pipeline, ui_info.ui.context["object"].project_info.config_file)
         if dialog.path != ui_info.ui.context["object"].project_info.config_file:
             shutil.copy(ui_info.ui.context["object"].project_info.config_file, dialog.path)
开发者ID:JohnGriffiths,项目名称:cmp_nipype,代码行数:7,代码来源:project.py

示例4: perform

    def perform(self, event):

        plot_component = self.container.component

        filter = 'PNG file (*.png)|*.png|\nTIFF file (*.tiff)|*.tiff|'
        dialog = FileDialog(action='save as', wildcard=filter)

        if dialog.open() != OK:
            return

        # Remove the toolbar before saving the plot, so the output doesn't
        # include the toolbar.
        plot_component.remove_toolbar()

        filename = dialog.path

        width, height = plot_component.outer_bounds

        gc = PlotGraphicsContext((width, height), dpi=72)
        gc.render_component(plot_component)
        try:
            gc.save(filename)
        except KeyError as e:
            errmsg = ("The filename must have an extension that matches "
                      "a graphics format, such as '.png' or '.tiff'.")
            if str(e.message) != '':
                errmsg = ("Unknown filename extension: '%s'\n" %
                          str(e.message)) + errmsg

            error(None, errmsg, title="Invalid Filename Extension")

        # Restore the toolbar.
        plot_component.add_toolbar()
开发者ID:enthought,项目名称:chaco,代码行数:33,代码来源:toolbar_buttons.py

示例5: _save_

    def _save_(self, type_='pic', path=None):
        """
        """
        if path is None:
            dlg = FileDialog(action='save as')
            if dlg.open() == OK:
                path = dlg.path
                self.status_text = 'Image Saved: %s' % path

        if path is not None:
            if type_ == 'pdf':
                self._render_to_pdf(filename=path)
            else:
                # auto add an extension to the filename if not present
                # extension is necessary for PIL compression
                # set default save type_ DEFAULT_IMAGE_EXT='.png'

                # see http://infohost.nmt.edu/tcc/help/pubs/pil/formats.html
                saved = False
                for ei in IMAGE_EXTENSIONS:
                    if path.endswith(ei):
                        self._render_to_pic(path)
                        saved = True
                        break

                if not saved:
                    self._render_to_pic(path + DEFAULT_IMAGE_EXT)
开发者ID:jirhiker,项目名称:pychron,代码行数:27,代码来源:graph.py

示例6: save_file

def save_file():
    wildcard='*.txt'
    dialog = FileDialog(title='Select the file to save as...',
        action='save as', wildcard=wildcard)
    if dialog.open() == Pyface_OK:
        return dialog.path
    return ''
开发者ID:JariLiski,项目名称:Yasso15,代码行数:7,代码来源:yasso.py

示例7: OpenFileDialog

def OpenFileDialog(action, wildcard, self):
    from pyface.api import FileDialog, OK
    doaction = action
    if action == "new":
        doaction = "save as"
    dialog = FileDialog(action=doaction, wildcard=wildcard)
    dialog.open()
    if dialog.return_code == OK:
        self.filedir = dialog.directory
        self.filename = dialog.filename
        self.Configuration_File = os.path.join(dialog.directory, dialog.filename)
        if action == "open":
            self._config = load_config(dialog.path, self.config_class)
            self._config.configure_traits(view=self.config_view())
            self.saved = False
            self.config_changed = True
        if action == "new":
            self._config = self.config_class()
            self._config.configure_traits(view=self.config_view())
            self._save_to_file()
            self.saved = False
            self.config_changed = True
        if action == "save as":
            self._save_to_file()
            self.saved = True
            self.config_changed = False
开发者ID:akeshavan,项目名称:BrainImagingPipelines,代码行数:26,代码来源:base.py

示例8: perform

    def perform(self, event):
        """ Performs the action. """
        mv = get_imayavi(self.window)
        s = get_scene(mv)
        if s is None:
            return

        wildcard = 'All files (*.*)|*.*'
        for src in registry.sources:
            if len(src.extensions) > 0:
                if wildcard.endswith('|') or \
                   src.wildcard.startswith('|'):
                       wildcard += src.wildcard
                else:
                    wildcard += '|' + src.wildcard

        parent = self.window.control
        dialog = FileDialog(parent=parent,
                            title='Open supported data file',
                            action='open', wildcard=wildcard
                            )
        if dialog.open() == OK:
            if not isfile(dialog.path):
                error("File '%s' does not exist!"%dialog.path, parent)
                return
            # FIXME: Ask for user input if a filetype is unknown and
            # choose appropriate reader.
            src = mv.open(dialog.path)
            if src is not None:
                mv.engine.current_selection = src
开发者ID:PerryZh,项目名称:mayavi,代码行数:30,代码来源:sources.py

示例9: parse_autoupdate

    def parse_autoupdate(self):
        '''
        '''

        f = FileDialog(action='open',
#                       default_directory=paths.modeling_data_dir
                       default_directory=self.data_directory
                       )
        if f.open() == OK:
            self.info('loading autoupdate file {}'.format(f.path))

            # open a autoupdate config dialog
            from clovera_configs import AutoUpdateParseConfig
            adlg = AutoUpdateParseConfig('', '')
            info = adlg.edit_traits()
            if info.result:
                self.info('tempoffset = {} (C), timeoffset = {} (min)'.format(adlg.tempoffset, adlg.timeoffset))
                rids = self.data_loader.load_autoupdate(f.path, adlg.tempoffset, adlg.timeoffset)
                auto_files = True
                if auto_files:
                    for rid in rids:
                        root = f.path + '_data'
                        with open(os.path.join(root, rid, 'samples.lst'), 'w') as s:
                            s.write('{}'.format(rid))

                        self.execute_files(rid=rid, root=root,
                                           block=True)
开发者ID:UManPychron,项目名称:pychron,代码行数:27,代码来源:modeler.py

示例10: _save_fired

 def _save_fired(self):
     import pickle
     import os.path
     # support the new traits api
     try:
       import apptools.sweet_pickle as sp        
     except ImportError:
       import enthought.sweet_pickle as sp 
     
     # support the new traits api
     try:
       from pyface.api import FileDialog, OK
     except ImportError: 
       from enthought.pyface.api import FileDialog, OK
     
     wildcard = "CMP Configuration State (*.pkl)|*.pkl|" \
                     "All files (*.*)|*.*"
     dlg = FileDialog(wildcard=wildcard,title="Filename to store configuration state",\
                      resizeable=False, action = 'save as', \
                      default_directory=self.subject_workingdir,)
     
     if dlg.open() == OK:
         if not dlg.path.endswith('.pkl'):
             dlg.path = dlg.path + '.pkl'
         self.save_state(dlg.path)
开发者ID:NicolasRannou,项目名称:cmp,代码行数:25,代码来源:gui.py

示例11: export_chaco_python

    def export_chaco_python(self, info):
        """Implements the "File / Export / Chaco python code" menu item."""

        dialog = FileDialog(
            parent=info.ui.control,
            default_filename=info.object.name + ".py",
            action="save as",
            title="Chaco python file",
        )
        if dialog.open() == OK:
            # The data is attached to the function as an attribute.  This
            # will allow a program to import a module, look for functions in
            # the module that have the _colormap_data attribute and recover
            # the data without having to call the function.
            f = open(dialog.path, "w")
            f.write("\n")
            f.write("from enthought.chaco.api import ColorMapper\n\n")
            f.write("def %s(range, **traits):\n" % info.object.name)
            f.write('    """Generator for the colormap "%s"."""\n' % info.object.name)
            f.write(
                ("    return ColorMapper.from_segment_map(" "%s._colormap_data, range=range, **traits)\n\n")
                % info.object.name
            )
            f.write("%s._colormap_data = " % info.object.name)
            segment_map = info.object.colormap_editor._segment_map()
            seg_code = "%r" % segment_map
            seg_code = seg_code.replace("'red'", "\n        'red'")
            seg_code = seg_code.replace("'green'", "\n        'green'")
            seg_code = seg_code.replace("'blue'", "\n        'blue'")
            seg_code = seg_code.replace("}", "\n        }")
            f.write(seg_code)
            f.close()
开发者ID:WarrenWeckesser,项目名称:chacoled,代码行数:32,代码来源:colormap_app.py

示例12: open_outputdbs

def open_outputdbs():
    """Open file"""
    wildcard = "Output files (*.dbx;*.exo)|*.dbx;*.exo|"
    dialog = FileDialog(action="open files", wildcard=wildcard)
    if dialog.open() != pyOK:
        return []
    return dialog.paths
开发者ID:sylm21,项目名称:fem-with-python,代码行数:7,代码来源:_ipane.py

示例13: save

 def save(self, ui_info):
     print self.view.save_image_file
     fd = FileDialog(action='save as', default_path=self.view.save_image_file)
     if fd.open() == OK:
         print 'Saving figure to ', fd.path
         self.view.save_image(fd.path)
         self.view.save_image_file = fd.path
开发者ID:vnoel,项目名称:vl3,代码行数:7,代码来源:controller.py

示例14: get_transformed_filename

def get_transformed_filename(filename):
    dialog = FileDialog(default_path=filename, action="save as", title="Save as", wildcard=xye_wildcard)
    if dialog.open() == OK:
        filename = dialog.path
        if filename:
            return filename
    return None
开发者ID:AustralianSynchrotron,项目名称:pdviper,代码行数:7,代码来源:ui_helpers.py

示例15: open

 def open(self):
     """ Shows a dialog to open a file.
     """
     logger.debug('PythonShellTask: opening file')
     dialog = FileDialog(parent=self.window.control, wildcard='*.py')
     if dialog.open() == OK:
         self._open_file(dialog.path)
开发者ID:OspreyX,项目名称:pyface,代码行数:7,代码来源:python_shell.py


注:本文中的pyface.api.FileDialog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。