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


Python api.FileDialog类代码示例

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


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

示例1: on_savefig

    def on_savefig ( self ):
        """ Handles the user requesting that the image of the function is to be saved.
        """
        import os
        dlg = FileDialog(parent = self.control, 
                         title = 'Save as image',
                         default_directory=os.getcwd(),
                         default_filename="", wildcard=WILDCARD,
                         action='save as')
        if dlg.open() == OK:
            path = dlg.path

            print "Saving plot to", path, "..."
            try:

                # Now we create a canvas of the appropriate size and ask it to render
                # our component.  (If we wanted to display this plot in a window, we
                # would not need to create the graphics context ourselves; it would be
                # created for us by the window.)
                self._plot.bounds = [500,300]
                self._plot.padding = 50
                plot_gc = PlotGraphicsContext(self._plot.outer_bounds)
                print self._plot.outer_bounds
                plot_gc.render_component(self._plot)

                # Finally, we tell the graphics context to save itself to disk as an image.
                plot_gc.save(path)
                
            except:
                print "Error saving!"
                raise
            print "Plot saved."
        return
开发者ID:axelvonderheide,项目名称:scratch,代码行数:33,代码来源:mfn_line_editor.py

示例2: 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, e:
            errmsg = "The filename must have an extension that matches a graphics"
            errmsg = errmsg + " 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")
开发者ID:brycehendrix,项目名称:chaco,代码行数:29,代码来源:toolbar_buttons.py

示例3: open_menu

 def open_menu(self):
     dlg = FileDialog()
     dlg.open()
     if dlg.return_code == OK:
         self.img.load_image(dlg.path)
         self.update_affine()
         self.update_slice_index()
开发者ID:alexsavio,项目名称:nidoodles,代码行数:7,代码来源:trait_viewer.py

示例4: on_savedata

    def on_savedata ( self ):
        """ Handles the user requesting that the data of the function is to be saved.
        """
        import os
        dlg = FileDialog(parent = self.control, 
                         title = 'Export function data',
                         default_directory=os.getcwd(),
                         default_filename="", wildcard='*.csv',
                         action='save as')
        if dlg.open() == OK:
            path = dlg.path

            print "Saving data to", path, "..."
            try:

#                factory  = self.factory
#                plotitem = factory.plotitem
#                x_values = getattr(self.object, plotitem.index)
#                y_values = getattr(self.object, plotitem.value)
                x_values = self.value.xdata
                y_values = self.value.ydata
                savetxt( path, vstack( (x_values,y_values) ).transpose() )
            except:
                print "Error saving!"
                raise
            print "Plot saved."
        return
开发者ID:axelvonderheide,项目名称:scratch,代码行数:27,代码来源:mfn_druckbewehrung_editor.py

示例5: on_savedata

    def on_savedata ( self ):
        """ Handles the user requesting that the data of the function is to be saved.
        """
        import os
        dlg = FileDialog(parent = self.control, 
                         title = 'Export function data',
                         default_directory=os.getcwd(),
                         default_filename="", wildcard='*.csv',
                         action='save as')
        if dlg.open() == OK:
            path = dlg.path

            print "Saving data to", path, "..."
            try:
                vectors = []
                x_values = self.value.xdata
                y_values = self.value.ydata
                #savetxt( path, vstack( (x_values, y_values[:,0], y_values[:,1], y_values[:,2]) ).transpose() )
                
                print 'y_values', y_values
                y_values_tr = y_values.transpose()
                for vector in y_values_tr[:]:
                    vectors.append(vector)

                savetxt( path, vstack( (x_values, vectors) ).transpose() )
                    
            except:
                print "Error saving!"
                raise
            print "Plot saved."
        return
开发者ID:axelvonderheide,项目名称:scratch,代码行数:31,代码来源:mfn_chaco_multiline_editor.py

示例6: on_savefig

    def on_savefig ( self ):
        """ Handles the user requesting that the image of the function is to be saved.
        """
        import os
        dlg = FileDialog(parent = self.control, 
                         title = 'Save as image',
                         default_directory=os.getcwd(),
                         default_filename="", wildcard=WILDCARD,
                         action='save as')
        if dlg.open() == OK:
            path = dlg.path

            print "Saving plot to", path, "..."
            try:
                # Now we create a canvas of the appropriate size and ask it to render
                # our component.  (If we wanted to display this plot in a window, we
                # would not need to create the graphics context ourselves; it would be
                # created for us by the window.)
                size=(650,400)
                gc = GraphicsContext(size)
                self.plot_container.draw(gc)
                gc.save(path)
            except:
                print "Error saving!"
                raise
            print "Plot saved."
        return
开发者ID:axelvonderheide,项目名称:scratch,代码行数:27,代码来源:mfn_chaco_multiline_editor.py

示例7: _save_as_button_fired

 def _save_as_button_fired(self):
     dialog = FileDialog(action="save as", wildcard=self.file_wildcard)
     dialog.open()
     if dialog.return_code == OK:
         self.filedir = dialog.directory
         self.filename = dialog.filename
         self._save_to_file()
开发者ID:labJunky,项目名称:LabDevices,代码行数:7,代码来源:Pyside_test5.py

示例8: perform

    def perform(self, event, cfile=None):
        """ Performs the action. """

        logger.info("Performing save connectome file action")

        # helper variable to use this function not only in the menubar
        exec_as_funct = True

        cfile = self.window.application.get_service("cviewer.plugins.cff2.cfile.CFile")

        wildcard = "Connectome File Format v2.0 (*.cff)|*.cff|" "All files (*.*)|*.*"

        dlg = FileDialog(
            wildcard=wildcard,
            title="Save as Connectome File",
            resizeable=False,
            action="save as",
            default_directory=preference_manager.cviewerui.cffpath,
        )

        if dlg.open() == OK:

            if (dlg.paths[0]).endswith(".cff"):

                cfflib.save_to_cff(cfile.obj, dlg.paths[0])
                logger.info("Saved connectome file to %s" % dlg.paths[0])
开发者ID:satra,项目名称:connectomeviewer,代码行数:26,代码来源:load_cff.py

示例9: on_savefig

    def on_savefig ( self ):
        """ Handles the user requesting that the image of the function is to be saved.
        """
        import os
        dlg = FileDialog(parent = self.control, 
                         title = 'Save as image',
                         default_directory=os.getcwd(),
                         default_filename="", wildcard=WILDCARD,
                         action='save as')
        if dlg.open() == OK:
            path = dlg.path

            print "Saving plot to", path, "..."
            try:

                # Now we create a canvas of the appropriate size and ask it to render
                # our component.  (If we wanted to display this plot in a window, we
                # would not need to create the graphics context ourselves; it would be
                # created for us by the window.)

               # plot_gc = PlotGraphicsContext(self._plot.outer_bounds)
               # plot_gc.render_component(self._plot)
                              
                #self._plot_container.outer_bounds = list((800,600))
#                plot_gc = PlotGraphicsContext((400,300), dpi=72.0)
#                plot_gc.render_component(self._plot_container)

#                self.line_plot.bounds = [500,300]
#                self.line_plot.padding = 50
#
#                win_size = self.line_plot.outer_bounds
#             #   win_size = self.component.outer_bounds
#                plot_gc = PlotGraphicsContext(win_size)
#        
#        
#                # Have the plot component into it
#                plot_gc.render_component(self.line_plot)
#
#                # Finally, we tell the graphics context to save itself to disk as an image.
#                plot_gc.save(path)

                DPI = 70.0
                size=(550,450)
             #   self.plot_container = create_plot()
                self.plot_container.bounds = list(size)
                self.plot_container.do_layout(force=True)
                
                gc = PlotGraphicsContext(size, dpi=DPI)
               

                #gc = GraphicsContext((size[0]+1, size[1]+1))
                gc.render_component(self.plot_container)
                gc.save(path)

                
            except:
                print "Error saving!"
                raise
            print "Plot saved."
        return
开发者ID:axelvonderheide,项目名称:scratch,代码行数:60,代码来源:mfn_druckbewehrung_editor.py

示例10: save_as

    def save_as(self, info):
        """ Handles saving the current model to file.
        """
        if not info.initialized:
            return

#        retval = self.edit_traits(parent=info.ui.control, view="file_view")

        dlg = FileDialog( action = "save as",
            wildcard = "Graphviz Files (*.dot, *.xdot, *.txt)|" \
                "*.dot;*.xdot;*.txt|Dot Files (*.dot)|*.dot|" \
                "All Files (*.*)|*.*|")

        if dlg.open() == OK:
            fd = None
            try:
                fd = open(dlg.path, "wb")
                dot_code = str(self.model)
                fd.write(dot_code)

                self.save_file = dlg.path

            except:
                error(parent=info.ui.control, title="Save Error",
                      message="An error was encountered when saving\nto %s"
                      % self.file)

            finally:
                if fd is not None:
                    fd.close()

        del dlg
开发者ID:jcrabtree,项目名称:godot,代码行数:32,代码来源:graph_view_model.py

示例11: _load_button_fired

 def _load_button_fired(self):
     dialog = FileDialog(action="open", wildcard='EQ files (*.eq)|*.eq')
     result = dialog.open()
     if result == OK:
         f = file(dialog.path, "rb")
         self.equalizers = pickle.load(f)
         f.close()
开发者ID:shark803,项目名称:PythonCodeFromBook,代码行数:7,代码来源:filter_equalizer_designer.py

示例12: _load_button_fired

 def _load_button_fired(self):
     dialog = FileDialog(action = "open", wildcard=self.file_wildcard)
     dialog.open()
     if dialog.return_code == OK:
         self.init(smear.RawData(dialog.path))
         #self.raw = smear.RawData(dialog.path, 'r')
         self.filename = dialog.filename
开发者ID:yggi,项目名称:smear,代码行数:7,代码来源:plotter.py

示例13: _save_button_fired

 def _save_button_fired(self):
     dialog = FileDialog(action="save as", wildcard='EQ files (*.eq)|*.eq')
     result = dialog.open()
     if result == OK:
         f = file(dialog.path, "wb")
         pickle.dump( self.equalizers , f)
         f.close()
开发者ID:shark803,项目名称:PythonCodeFromBook,代码行数:7,代码来源:filter_equalizer_designer.py

示例14: _dialog

    def _dialog(self, message="Select Folder",  new_directory=True,mode='r'):
        """Creates a file dialog box for working with

        @param message Message to display in dialog
        @param new_file True if allowed to create new directory
        @return A directory to be used for the file operation."""
        try:
            from enthought.pyface.api import FileDialog, OK
        except ImportError:
            from pyface.api import FileDialog, OK
        # Wildcard pattern to be used in file dialogs.
        file_wildcard = "hdf file (*.hdf5)|*.hdf5|Data file (*.dat)|\
        *.dat|All files|*"

        if mode == "r":
            mode2 = "open"
        elif mode == "w":
            mode2 = "save as"

        if self.directory is not None:
            filename = path.basename(path.realpath(self.directory))
            dirname = path.dirname(path.realpath(self.directory))
        else:
            filename = ""
            dirname = ""
        dlg = FileDialog(action=mode2, wildcard=file_wildcard)
        dlg.open()
        if dlg.return_code == OK:
            self.directory = dlg.path
            self.File=h5py.File(self.directory,mode)
            self.File.close()
            return self.directory
        else:
            return None
开发者ID:mattnewman,项目名称:Stoner-PythonCode,代码行数:34,代码来源:HDF5.py

示例15: open_file

def open_file(window, path=None):
    if path==None:
        wildcard="|".join([
            "All files (*)", "*",
            "Hermes2D mesh files (*.mesh)", "*.mesh",
            "Agros2D problem files (*.a2d)", "*.a2d",
            ])
        dialog = FileDialog(parent=None, title='Open supported data file',
                            action='open', wildcard=wildcard,
                            # use this to have Hermes2D by default:
                            #wildcard_index=1,
                            wildcard_index=0,
                            default_directory=get_data_dir(),
                            #default_filename="lshape.mesh",
                            )
        if dialog.open() == OK:
            path = dialog.path
        else:
            return
    ext = os.path.splitext(path)[1]
    if ext == ".a2d":
        scene = window.get_view_by_id("Problem")
        p, g = read_a2d(path)
        scene.problem = p
        scene.geometry = g
    else:
        scene = window.get_view_by_id("Scene")
        mesh = read_mesh(path)
        scene.mesh = mesh
        scene.mode = "mesh"
开发者ID:adam-urbanczyk,项目名称:hermes-gui,代码行数:30,代码来源:action_set.py


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