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


Python FileDialog.create_wildcard方法代码示例

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


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

示例1: save

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
 def save(self):
     extensions = [ '*.bmp', '*.gif', '*.jpg', '*.pdf',
                    '*.png', '*.svg', '*.tif', '*.xbm' ]
     wildcard = FileDialog.create_wildcard('From file name', extensions)
     dialog = FileDialog(action = 'save as',
                         default_directory = self.default_directory,
                         parent = self.window.control,
                         wildcard = wildcard)
     if dialog.open() == OK:
         filename = dialog.path
         extension = os.path.splitext(filename)[1]
         if not extension:
             extension = '.png'
             filename += extension
         try:
             # FIXME: Expose size and background color?
             self.editor_area.active_editor.save(filename, bgcolor='white')
         except Exception as exc:
             msg = 'Failed to save image in %s format' % extension.upper()
             dialog = MessageDialog(title = 'Error saving',
                                    message = msg,
                                    detail = str(exc),
                                    parent = self.window.control,
                                    severity = 'error')
             dialog.open()
开发者ID:rmkatti,项目名称:surf_2012,代码行数:27,代码来源:task.py

示例2: resize_and_save_matplotlib_figure

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
def resize_and_save_matplotlib_figure(figure):        
    ''' To save a matplotlib figure with custom width and height in pixels 
    requires changing the bounding box while is being rendered! '''
   
    # get figure size
    figure_size = MatplotlibFigureSize(figure=figure)
    old_dpi = figure_size.dpi
    old_width_inches = figure_size.width_inches
    old_height_inches = figure_size.height_inches
    ui = figure_size.edit_traits(kind='modal')
    widget = ui.control
    # maybe change figure size
    if ui.result:
        figure.dpi = figure_size.dpi # set new dpi
        figure.bbox_inches.p1 = figure_size.width_inches, figure_size.height_inches # set new width and height in inches
    else:
        return

    # get file name with (correct choice of formats)
    fd = FileDialog(
        action='save as',
        wildcard=FileDialog.create_wildcard('All available formats', ['*.eps', '*.png', '*.pdf', '*.ps', '*.svg']),
    )
    if fd.open() != OK:
        return
    file_name = fd.path
    
    # save it
    figure.savefig(file_name)

    # restore original figure size
    figure.dpi = old_dpi # restore old dpi
    figure.bbox_inches.p1 = old_width_inches, old_height_inches # restore old width and height in inches
开发者ID:jvb,项目名称:infobiotics-dashboard,代码行数:35,代码来源:matplotlib_figure_size.py

示例3: _savePlot_fired

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
 def _savePlot_fired(self):
     dialog = FileDialog(title='Save plot as...', action='save as',
                         wildcard = FileDialog.create_wildcard('Portable Network Graphics', '*.png'))
     if not dialog.open():
         self.add_line("ERROR opening save file.")
         return
     self.plotRU(save=True,filename=dialog.path)
开发者ID:BackgroundNose,项目名称:Vibromatic,代码行数:9,代码来源:quantumWobbler.py

示例4: open

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
 def open(self):
     wildcard = FileDialog.create_wildcard('JSON files', '*.json')
     dialog = FileDialog(action = 'open',
                         default_directory = self.default_directory,
                         parent = self.window.control,
                         wildcard = wildcard)
     if dialog.open() == OK:
         runner = load(dialog.path)
         runner.outfile = dialog.path
         self.editor_area.edit(runner)
开发者ID:rmkatti,项目名称:surf_2012,代码行数:12,代码来源:task.py

示例5: _saveLog_fired

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
 def _saveLog_fired(self):
     dialog = FileDialog(title='Save plot as...', action='save as',
                         wildcard = FileDialog.create_wildcard('Text file', '*.txt'))
     if not dialog.open():
         self.add_line("ERROR opening save file.")
         return
     try:
         out = open(dialog.path,'w')
         out.write(self.results)
         out.close()
     except IOError:
         self.add_line("I failed to open "+str(dialog.path))
         return
开发者ID:BackgroundNose,项目名称:Vibromatic,代码行数:15,代码来源:quantumWobbler.py

示例6: perform

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
    def perform(self, event=None):
        fd = FileDialog(
            wildcard=FileDialog.create_wildcard('PModelChecker results files', ['*.psm', '*.mc2']),
            title='Select a PModelChecker results file',
        )
        if fd.open() != OK:
            return
        commons.edit_pmodelchecker_results_file(
            file=fd.path,
#            application=self.application,
#            application=self.window.application,
            application=self.window.workbench.application,
        )
开发者ID:jvb,项目名称:infobiotics-dashboard,代码行数:15,代码来源:actions.py

示例7: save_as

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
    def save_as(self):
        ''' Saves the file to disk after prompting for the file name. '''
        dialog = FileDialog(
            parent=self.window.control,
            action='save as',
            default_filename=self.name,
            wildcard='\n'.join([FileDialog.create_wildcard(wildcard[0], ', '.join(wildcard[1])) for wildcard in self.wildcards]) if len(self.wildcards) > 0 else FileDialog.create_wildcard('All files', '*')
        )
        if dialog.open() != CANCEL:

            # update this editor
            self.id = dialog.path
            self.name = os.path.basename(dialog.path)

            self.obj.path = dialog.path # update obj (an apptools.io.api.File) 

            self.save() # save it now it has a path
开发者ID:jvb,项目名称:infobiotics-dashboard,代码行数:19,代码来源:abstract_file_editor.py

示例8: click

# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import create_wildcard [as 别名]
    def click ( self ):
        """ Handles the user left clicking on the feature image.
        """
        # Create the file dialog:
        fd = FileDialog()

        # Set up the default path based on the current value (if any):
        default_path = getattr( self.dock_control.object, self.name, None )
        if default_path is not None:
            fd.default_path = default_path

        # Set up the appropriate extension filters (if any):
        if len( self.extensions ) > 0:
            fd.wildcard = '\n'.join([ FileDialog.create_wildcard('', '*' + ext)
                                      for ext in self.extensions ])

        # Display the file dialog, and if successful, set the new file name:
        if fd.open() == OK:
            self.drop( fd.path )
开发者ID:enthought,项目名称:etsdevtools,代码行数:21,代码来源:drop_file_feature.py


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