Python tkFileDialog 模块,asksaveasfilename() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用tkFileDialog.asksaveasfilename()

项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def saveBox(
            self,
            title=None,
            fileName=None,
            dirName=None,
            fileExt=".txt",
            fileTypes=None,
            asFile=False):
        self.topLevel.update_idletasks()
        if fileTypes is None:
            fileTypes = [('all files', '.*'), ('text files', '.txt')]
        # define options for opening
        options = {}
        options['defaultextension'] = fileExt
        options['filetypes'] = fileTypes
        options['initialdir'] = dirName
        options['initialfile'] = fileName
        options['title'] = title

        if asFile:
            return filedialog.asksaveasfile(mode='w', **options)
        # will return "" if cancelled
        else:
            return filedialog.asksaveasfilename(**options)
项目:Tweezer_design    作者:AntoineRiaud    | 项目源码 | 文件源码
def IDT_group2svg(IDT_group):
    IDT_group_dir = IDT_group['IDT_group_dir']
    Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
    svg_filename = tkFileDialog.asksaveasfilename(title='SVG export filename',defaultextension = 'svg',initialdir = IDT_group_dir);
    plt_bnds = [0,8000,0,8000]
    x0 = 40e-3
    y0 = 40e-3
    factor = 1e5
    fig, ax = plt.subplots()    
    for polygon in IDT_group['final_IDT']:
        polygon = shapely_affinity.translate(polygon, xoff=x0, yoff=y0) 
        polygon = shapely_affinity.scale(polygon, xfact = factor, yfact= factor, origin=(0,0,0))
        patch = PolygonPatch(polygon, fc=BLACK, ec=None, alpha=1.0, zorder=2)
        ax.add_patch(patch)
    for IDT_data in IDT_group['IDT']:
        reticule = IDT_data['reticule']
        for polygon in reticule:
            polygon = shapely_affinity.translate(polygon, xoff=x0, yoff=y0) 
            polygon = shapely_affinity.scale(polygon, xfact = factor, yfact= factor, origin=(0,0,0))
            patch = PolygonPatch(polygon, fc=BLACK, ec='none', alpha=1.0, zorder=2)
            ax.add_patch(patch)
    ax.axis(plt_bnds)
    ax.set_aspect(1)
    #plt.show() 
    fig.savefig(svg_filename, format='svg', dpi=1200)
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def saveBox(
            self,
            title=None,
            fileName=None,
            dirName=None,
            fileExt=".txt",
            fileTypes=None,
            asFile=False):
        self.topLevel.update_idletasks()
        if fileTypes is None:
            fileTypes = [('all files', '.*'), ('text files', '.txt')]
        # define options for opening
        options = {}
        options['defaultextension'] = fileExt
        options['filetypes'] = fileTypes
        options['initialdir'] = dirName
        options['initialfile'] = fileName
        options['title'] = title

        if asFile:
            return filedialog.asksaveasfile(mode='w', **options)
        # will return "" if cancelled
        else:
            return filedialog.asksaveasfilename(**options)
项目:ATX    作者:NetEaseGame    | 项目源码 | 文件源码
def _save_crop(self):
        log.debug('crop bounds: %s', self._bounds)
        if self._bounds is None:
            return
        bounds = self.select_bounds
        # ext = '.%dx%d.png' % tuple(self._size)
        # tkFileDialog doc: http://tkinter.unpythonic.net/wiki/tkFileDialog
        save_to = tkFileDialog.asksaveasfilename(**dict(
            initialdir=self._save_parent_dir,
            defaultextension=".png",
            filetypes=[('PNG', ".png")],
            title='Select file'))
        if not save_to:
            return
        save_to = self._fix_path(save_to)
        # force change extention with info (resolution and offset)
        save_to = os.path.splitext(save_to)[0] + self._fileext_text.get()

        self._save_parent_dir = os.path.dirname(save_to)

        log.info('Crop save to: %s', save_to)
        self._image.crop(bounds).save(save_to)
        self._genfile_name.set(os.path.basename(save_to))
        self._gencode_text.set('d.click_image(r"%s")' % save_to)
项目:AutomatorX    作者:xiaoyaojjian    | 项目源码 | 文件源码
def _save_crop(self):
        log.debug('crop bounds: %s', self._bounds)
        if self._bounds is None:
            return
        bounds = self.select_bounds
        # ext = '.%dx%d.png' % tuple(self._size)
        # tkFileDialog doc: http://tkinter.unpythonic.net/wiki/tkFileDialog
        save_to = tkFileDialog.asksaveasfilename(**dict(
            initialdir=self._save_parent_dir,
            defaultextension=".png",
            filetypes=[('PNG', ".png")],
            title='Select file'))
        if not save_to:
            return
        save_to = self._fix_path(save_to)
        # force change extention with info (resolution and offset)
        save_to = os.path.splitext(save_to)[0] + self._fileext_text.get()

        self._save_parent_dir = os.path.dirname(save_to)

        log.info('Crop save to: %s', save_to)
        self._image.crop(bounds).save(save_to)
        self._genfile_name.set(os.path.basename(save_to))
        self._gencode_text.set('d.click_image(r"%s")' % save_to)
项目:NaiveCCompiler    作者:crisb-DUT    | 项目源码 | 文件源码
def Save_As(self, app, pad):
        """
        saves the contents in pad to file
        to specified filename
        """
        save_file = asksaveasfilename(parent=app)
        data = pad.get('1.0', GUI.END)[:-1]
        f = open(save_file, 'w')
        f.write(data)
        f.close()
        x = save_file
        if platform.system() == 'Windows':
            x = x.replace('/', '\\')
            File.filename(map(str, x.split('\\'))[-1])
        else:
            pass
        File.filepath(x)
        app.title(File.name)
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def save_selection(self, mode="selection"):
        """
        Save selection in a single file.
        """
        # Builds the selection.
        selection = None
        if mode == "selection":
            selection = self.get_selected_sequences()
        elif mode == "all":
            selection = self.get_all_sequences()

        # Ask users if they want to include indels in the sequences to save.
        remove_indels_choice = False
        for e in selection:
            if "-" in e.my_sequence:
                remove_indels_choice = tkMessageBox.askyesno(message="Would you like to remove indels from the sequences when saving them to a file?", title="Save Selection", parent=self.main_window)
                break

        # Ask users to chose a directory where to save the files.
        filepath=asksaveasfilename(filetypes=[("fasta","*.fasta")],parent=self.main_window)
        if not filepath == "":
            dirpath = os.path.dirname(filepath)
            filename = os.path.splitext(os.path.basename(filepath))[0]
            self.build_sequences_file(selection, filename, file_format="fasta", remove_indels=remove_indels_choice, use_structural_information=False, new_directory=dirpath)
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def saveBox(
            self,
            title=None,
            fileName=None,
            dirName=None,
            fileExt=".txt",
            fileTypes=None,
            asFile=False):
        self.topLevel.update_idletasks()
        if fileTypes is None:
            fileTypes = [('all files', '.*'), ('text files', '.txt')]
        # define options for opening
        options = {}
        options['defaultextension'] = fileExt
        options['filetypes'] = fileTypes
        options['initialdir'] = dirName
        options['initialfile'] = fileName
        options['title'] = title

        if asFile:
            return filedialog.asksaveasfile(mode='w', **options)
        # will return "" if cancelled
        else:
            return filedialog.asksaveasfilename(**options)
项目:360fy-360_video_creator    作者:SapneshNaik    | 项目源码 | 文件源码
def action_inject(self):
        """Inject metadata into a new save file."""
        split_filename = os.path.splitext(ntpath.basename(self.in_file))
        base_filename = split_filename[0]
        extension = split_filename[1]
        self.save_options["initialfile"] = (base_filename
                                            + "_injected" + extension)
        self.save_file = tkFileDialog.asksaveasfilename(**self.save_options)
        if not self.save_file:
            return

        self.set_message("Saving file to %s" % ntpath.basename(self.save_file))

        # Launch injection on a separate thread after disabling buttons.
        self.disable_state()
        self.master.after(100, self.action_inject_delay)
项目:rensapy    作者:RensaProject    | 项目源码 | 文件源码
def save_grammar(self, *args):
        filename = asksaveasfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                     defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                pickle.dump((self._chart, self._tokens), open(filename, 'w'))
            else:
                file = open(filename, 'w')
                prods = self._grammar.productions()
                start = [p for p in prods if p.lhs() == self._grammar.start()]
                rest = [p for p in prods if p.lhs() != self._grammar.start()]
                for prod in start: file.write('%s\n' % prod)
                for prod in rest: file.write('%s\n' % prod)
                file.close()
        except Exception, e:
            tkMessageBox.showerror('Error Saving Grammar',
                                   'Unable to open file: %r' % filename)
项目:rensapy    作者:RensaProject    | 项目源码 | 文件源码
def print_to_file(self, filename=None):
        """
        Print the contents of this C{CanvasFrame} to a postscript
        file.  If no filename is given, then prompt the user for one.

        @param filename: The name of the file to print the tree to.
        @type filename: C{string}
        @rtype: C{None}
        """
        if filename is None:
            from tkFileDialog import asksaveasfilename
            ftypes = [('Postscript files', '.ps'),
                      ('All files', '*')]
            filename = asksaveasfilename(filetypes=ftypes,
                                         defaultextension='.ps')
            if not filename: return
        (x0, y0, w, h) = self.scrollregion()
        self._canvas.postscript(file=filename, x=x0, y=y0,
                                width=w+2, height=h+2,
                                pagewidth=w+2, # points = 1/72 inch
                                pageheight=h+2, # points = 1/72 inch
                                pagex=0, pagey=0)
项目:RePhraser    作者:MissLummie    | 项目源码 | 文件源码
def save_grammar(self, *args):
        filename = asksaveasfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                     defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                pickle.dump((self._chart, self._tokens), open(filename, 'w'))
            else:
                file = open(filename, 'w')
                prods = self._grammar.productions()
                start = [p for p in prods if p.lhs() == self._grammar.start()]
                rest = [p for p in prods if p.lhs() != self._grammar.start()]
                for prod in start: file.write('%s\n' % prod)
                for prod in rest: file.write('%s\n' % prod)
                file.close()
        except Exception, e:
            tkMessageBox.showerror('Error Saving Grammar',
                                   'Unable to open file: %r' % filename)
项目:RePhraser    作者:MissLummie    | 项目源码 | 文件源码
def print_to_file(self, filename=None):
        """
        Print the contents of this C{CanvasFrame} to a postscript
        file.  If no filename is given, then prompt the user for one.

        @param filename: The name of the file to print the tree to.
        @type filename: C{string}
        @rtype: C{None}
        """
        if filename is None:
            from tkFileDialog import asksaveasfilename
            ftypes = [('Postscript files', '.ps'),
                      ('All files', '*')]
            filename = asksaveasfilename(filetypes=ftypes,
                                         defaultextension='.ps')
            if not filename: return
        (x0, y0, w, h) = self.scrollregion()
        self._canvas.postscript(file=filename, x=x0, y=y0,
                                width=w+2, height=h+2,
                                pagewidth=w+2, # points = 1/72 inch
                                pageheight=h+2, # points = 1/72 inch
                                pagex=0, pagey=0)
项目:Verideals    作者:Derrreks    | 项目源码 | 文件源码
def save_grammar(self, *args):
        filename = asksaveasfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                     defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                pickle.dump((self._chart, self._tokens), open(filename, 'w'))
            else:
                file = open(filename, 'w')
                prods = self._grammar.productions()
                start = [p for p in prods if p.lhs() == self._grammar.start()]
                rest = [p for p in prods if p.lhs() != self._grammar.start()]
                for prod in start: file.write('%s\n' % prod)
                for prod in rest: file.write('%s\n' % prod)
                file.close()
        except Exception, e:
            tkMessageBox.showerror('Error Saving Grammar',
                                   'Unable to open file: %r' % filename)
项目:Verideals    作者:Derrreks    | 项目源码 | 文件源码
def print_to_file(self, filename=None):
        """
        Print the contents of this C{CanvasFrame} to a postscript
        file.  If no filename is given, then prompt the user for one.

        @param filename: The name of the file to print the tree to.
        @type filename: C{string}
        @rtype: C{None}
        """
        if filename is None:
            from tkFileDialog import asksaveasfilename
            ftypes = [('Postscript files', '.ps'),
                      ('All files', '*')]
            filename = asksaveasfilename(filetypes=ftypes,
                                         defaultextension='.ps')
            if not filename: return
        (x0, y0, w, h) = self.scrollregion()
        self._canvas.postscript(file=filename, x=x0, y=y0,
                                width=w+2, height=h+2,
                                pagewidth=w+2, # points = 1/72 inch
                                pageheight=h+2, # points = 1/72 inch
                                pagex=0, pagey=0)
项目:adtree-py    作者:uraplutonium    | 项目源码 | 文件源码
def save_sigma_file():
  """Brings up a file dialog box, so the user can choose a
  file for saving the current SIGMA diagram. Then converts
  the diagram to XML and saves it."""
  import tkFileDialog
  savefile = tkFileDialog.asksaveasfilename(
    filetypes=[("SIGMA Diagram files", ".igm")],
    defaultextension=".igm")
  if savefile:
    dom = makeSigmaDOM()
    try:
      f = open(savefile, "w")
      dom.writexml(f)
      f.close()
      #global DIRTY; DIRTY = False
    except:
        print "Couldn't write the file: ", savefile
        raise
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def onSave(self):
        filename = asksaveasfilename()
        if filename:
            alltext = self.gettext()                      
            open(filename, 'w').write(alltext)
项目:merac-o-matic    作者:RogueAI42    | 项目源码 | 文件源码
def browseForFile(TkStringVar):
    TkStringVar.set(tkFileDialog.asksaveasfilename())

# Tkinter doesn't let you send arguments to functions, so we must make wrapper functions:
项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def save():
    output1 = textbox.get(1.0, END)
    str(output1)
    filename = tkFileDialog.asksaveasfilename()
    fileit = open(filename, "w")
    fileit.write(output1)
项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def saveit():
    try:
        output1 = textbox.get(1.0, END)
        str(output1)
        filename = tkFileDialog.asksaveasfilename()
        entry2.insert(END, filename)
        fileit = open(filename, "w")
        fileit.write(output1)
    except:
        textbox.insert(END, "Failed Saving Data\n")
项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def setOutputFile(self):
        self.outputfile = tkFileDialog.asksaveasfilename()
        self.browseButtonText.set(self.outputfile)
项目:ATX    作者:NetEaseGame    | 项目源码 | 文件源码
def _save_screenshot(self):
        save_to = tkFileDialog.asksaveasfilename(**dict(
            defaultextension=".png",
            filetypes=[('PNG', '.png')],
            title='Select file'))
        if not save_to:
            return
        log.info('Save to: %s', save_to)
        self._image.save(save_to)
项目:tadtool    作者:vaquerizaslab    | 项目源码 | 文件源码
def on_click_save_tads(self, event):
        tk.Tk().withdraw()  # Close the root window
        save_path = filedialog.asksaveasfilename()
        if save_path is not None:
            with open(save_path, 'w') as o:
                for region in self.tad_regions:
                    o.write("%s\t%d\t%d\n" % (region.chromosome, region.start-1, region.end))
项目:tadtool    作者:vaquerizaslab    | 项目源码 | 文件源码
def on_click_save_vector(self, event):
        tk.Tk().withdraw()  # Close the root window
        save_path = filedialog.asksaveasfilename()
        if save_path is not None:
            da_sub = self.da[self.current_da_ix]
            with open(save_path, 'w') as o:
                for i, region in enumerate(self.regions):
                    o.write("%s\t%d\t%d\t.\t%e\n" % (region.chromosome, region.start-1, region.end, da_sub[i]))
项目:tadtool    作者:vaquerizaslab    | 项目源码 | 文件源码
def on_click_save_matrix(self, event):
        tk.Tk().withdraw()  # Close the root window
        save_path = filedialog.asksaveasfilename()
        if save_path is not None:
            with open(save_path, 'w') as o:
                # write regions
                for i, region in enumerate(self.regions):
                    o.write("%s:%d-%d" % (region.chromosome, region.start-1, region.end))
                    if i < len(self.regions)-1:
                        o.write("\t")
                    else:
                        o.write("\n")

                # write matrix
                n_rows = self.da.shape[0]
                n_cols = self.da.shape[1]
                for i in range(n_rows):
                    window_size = self.ws[i]
                    o.write("%d\t" % window_size)

                    for j in range(n_cols):
                        o.write("%e" % self.da[i, j])
                        if j < n_cols-1:
                            o.write("\t")
                        else:
                            o.write("\n")
项目:goreviewpartner    作者:pnprog    | 项目源码 | 文件源码
def save_as_ps(self,e=None):
        filename = tkFileDialog.asksaveasfilename(parent=self.parent,title='Choose a filename',filetypes = [('Postscript', '.ps')],initialfile=self.graph_mode.get()+' graph.ps')
        self.chart.postscript(file=filename, colormode='color')
项目:goreviewpartner    作者:pnprog    | 项目源码 | 文件源码
def save_as_ps(self,e=None):
        filename = tkFileDialog.asksaveasfilename(parent=self.parent,title='Choose a filename',filetypes = [('Postscript', '.ps')],initialfile='variation_move'+str(self.move)+'.ps')
        self.goban.postscript(file=filename, colormode='color')
项目:goreviewpartner    作者:pnprog    | 项目源码 | 文件源码
def save_left_as_ps(self,e=None):
        filename = tkFileDialog.asksaveasfilename(parent=self.parent,title='Choose a filename',filetypes = [('Postscript', '.ps')],initialfile='move'+str(self.current_move)+'.ps')
        self.goban1.postscript(file=filename, colormode='color')
项目:goreviewpartner    作者:pnprog    | 项目源码 | 文件源码
def save_right_as_ps(self,e=None):
        filename = tkFileDialog.asksaveasfilename(parent=self.parent,title='Choose a filename',filetypes = [('Postscript', '.ps')],initialfile='move'+str(self.current_move)+'.ps')
        self.goban2.postscript(file=filename, colormode='color')
项目:pyTSEB    作者:hectornieto    | 项目源码 | 文件源码
def _get_output_filename(self, title='Select Output File'):
        root, _, asksaveasfilename = self._setup_tkinter()
        # show an "Open" dialog box and return the path to the selected file
        output_file = asksaveasfilename(title=title)
        root.destroy()  # Destroy the GUI
        return output_file
项目:pyTSEB    作者:hectornieto    | 项目源码 | 文件源码
def _setup_tkinter(self):
        '''Creates a Tkinter input file dialog'''

        # Import Tkinter GUI widgets
        if sys.version_info.major == 2:
            from tkFileDialog import askopenfilename, asksaveasfilename
            import Tkinter as tk
        else:
            from tkinter.filedialog import askopenfilename, asksaveasfilename
            import tkinter as tk

        # Code below is to make sure the file dialog appears above the
        # terminal/browser
        # Based on
        # http://stackoverflow.com/questions/3375227/how-to-give-tkinter-file-dialog-focus

        # Make a top-level instance and hide since it is ugly and big.
        root = tk.Tk()
        root.withdraw()

        # Make it almost invisible - no decorations, 0 size, top left corner.
        root.overrideredirect(True)
        root.geometry('0x0+0+0')

        # Show window again and lift it to top so it can get focus,
        # otherwise dialogs will end up behind the terminal.
        root.deiconify()
        root.lift()
        root.focus_force()

        return root, askopenfilename, asksaveasfilename
项目:AutomatorX    作者:xiaoyaojjian    | 项目源码 | 文件源码
def _save_screenshot(self):
        save_to = tkFileDialog.asksaveasfilename(**dict(
            defaultextension=".png",
            filetypes=[('PNG', '.png')],
            title='Select file'))
        if not save_to:
            return
        log.info('Save to: %s', save_to)
        self._image.save(save_to)
项目:Tweezer_design    作者:AntoineRiaud    | 项目源码 | 文件源码
def IDTgroup2svg(IDT_group):
    IDT_group_dir = IDT_group['IDT_group_dir']
    Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
    svg_filename = tkFileDialog.asksaveasfilename(title='Wafer routing filename',defaultextension = 'svg',initialdir = IDT_group_dir);
    svg_dwg = SVGT.Init_svg(svg_filename)
    for IDT_data in IDT_group['IDT']:    
        IDT2svg(IDT_data,svg_dwg)
    svg_dwg.save();    
    IDT_group['svg_route']=svg_filename
项目:Tweezer_design    作者:AntoineRiaud    | 项目源码 | 文件源码
def IDT_group2gds(IDT_group):
    IDT_group_dir = IDT_group['IDT_group_dir']
    Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
    gds_filename = tkFileDialog.asksaveasfilename(title='Wafer gds filename',defaultextension = 'gds',initialdir = IDT_group_dir);
    layout = gds.core.Layout('LIBRARY')
    cell = gds.core.Cell('Main')
    for polygon in IDT_group['final_IDT']:
        points_exterior =  1e6*array(polygon.exterior.coords) #best practice: dimensions in um        
        points_interior_has_to_be_created  = True       
        for interior_ring in polygon.interiors:
            if points_interior_has_to_be_created:
                points_interior = 1e6*array(interior_ring.coords)
                points_interior_has_to_be_created = False
            else:
                points_interior = vstack((points_interior,1e6*array(interior_ring.coords)))       
        if not polygon.interiors:
            boundaries = gds.core.Boundary(points_exterior) 
        else:
            boundaries = gds.core.Boundary(vstack((points_interior,points_exterior))) 
        cell.add(boundaries)
    for IDT_data in IDT_group['IDT']:
        reticule = IDT_data['reticule']
        for polygon in reticule:
            points = 1e6*array(polygon.exterior.coords)
            boundaries = gds.core.Boundary(points)
            cell.add(boundaries)
    layout.add(cell)
    layout.save(gds_filename)
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def export_models(self):
        if self._check_run():
            filename = tkfile.asksaveasfilename(title = "Export models",
                                                filetypes = [ ("Pickle", ".pickle") ],
                                                defaultextension = ".pickle")
            if len(filename) > 0:
                with open(filename, "wb") as f:
                    pickle.dump(self.solver.models, f, protocol = pickle.HIGHEST_PROTOCOL)
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def export_fitness(self):
        if self._check_run():
            filename = tkfile.asksaveasfilename(title = "Export fitness",
                                                filetypes = [ ("Pickle", ".pickle") ],
                                                defaultextension = ".pickle")
            if len(filename) > 0:
                with open(filename, "wb") as f:
                    pickle.dump(self.solver.energy, f, protocol = pickle.HIGHEST_PROTOCOL)
项目:multi-contact-zmp    作者:stephane-caron    | 项目源码 | 文件源码
def save_as(self, path=None):
        if path:
            return motion_plan.dump(path)
        if motion_plan.path:
            initialdir, initialfile = os.path.split(motion_plan.path)
            path = tkFileDialog.asksaveasfilename(
                parent=self.master, initialfile=initialfile,
                initialdir=initialdir)
        else:
            path = tkFileDialog.asksaveasfilename(parent=self.master)
        if path:
            motion_plan.dump(path)
项目:G71    作者:nkp216    | 项目源码 | 文件源码
def Get_Save_File(self):

        if self.load_filename==None:
            showwarning("Export G-Code", "Nothing to export!")
            return

        myFormats = [('G-Code for EMC2','*.ngc'),\
        ('All File','*.*') ]

        (beg, ende)=os.path.split(self.load_filename)
        (fileBaseName, fileExtension)=os.path.splitext(ende)

        inidir=self.config.save_path
        self.save_filename = asksaveasfilename(initialdir=inidir,\
                               initialfile=fileBaseName +'.ngc',filetypes=myFormats)
项目:G71    作者:nkp216    | 项目源码 | 文件源码
def Get_Save_File(self):

        if self.load_filename==None:
            showwarning("Export G-Code", "Nothing to export!")
            return

        myFormats = [('G-Code for EMC2','*.ngc'),\
        ('All File','*.*') ]

        (beg, ende)=os.path.split(self.load_filename)
        (fileBaseName, fileExtension)=os.path.splitext(ende)

        inidir=self.config.save_path
        self.save_filename = asksaveasfilename(initialdir=inidir,\
                               initialfile=fileBaseName +'.ngc',filetypes=myFormats)
项目:VisualPython    作者:RobinManoli    | 项目源码 | 文件源码
def save(self, editor):
        if not editor.f:
            fpathname = asksaveasfilename()
            if not fpathname:
                # file not saved
                return False
            editor.open(fpathname)
        self.write(editor=editor)
        # file saved
        return True
项目:rapidpythonprogramming    作者:thecount12    | 项目源码 | 文件源码
def filesavebox(msg=None
    , title=None
    , default=""
    , filetypes=None
    ):
    """
    A file to get the name of a file to save.
    Returns the name of a file, or None if user chose to cancel.

    The "default" argument should contain a filename (i.e. the
    current name of the file to be saved).  It may also be empty,
    or contain a filemask that includes wildcards.

    The "filetypes" argument works like the "filetypes" argument to
    fileopenbox.
    """

    boxRoot = Tk()
    boxRoot.withdraw()

    initialbase, initialfile, initialdir, filetypes = fileboxSetup(default,filetypes)

    f = tk_FileDialog.asksaveasfilename(parent=boxRoot
        , title=getFileDialogTitle(msg,title)     
        , initialfile=initialfile
        , initialdir=initialdir
        , filetypes=filetypes
        )
    boxRoot.destroy()     
    if not f: return None
    return os.path.normpath(f)


#-------------------------------------------------------------------
#
# fileboxSetup
#
#-------------------------------------------------------------------
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def export_data(self):
        if self.canvas_plot.plots_list != []:
            filepath = tkFileDialog.asksaveasfilename(filetypes=[("csv","*.csv")],parent=self)
            if not filepath == "":
                try:
                    output_file_handler = open(filepath,"w")
                    print >> output_file_handler, self.canvas_plot.export_to_csv()
                    output_file_handler.close()
                except:
                    pass
        else:
            tkMessageBox.showerror("Export Error", "No data to export.", parent=self)
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def save_postscript(self):
        filepath = tkFileDialog.asksaveasfilename(filetypes=[("ps","*.ps")],parent=self)
        if not filepath == "":
            try:
                # Lowers the stack level of the points in order to hide them in the .ps image.
                self.canvas_plot.tag_lower("type:point")
                self.canvas_plot.postscript(file=filepath, colormode='color')
                self.canvas_plot.set_canvas_stack()
            except:
                pass
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def save_new_project_from_main_menu(self):
        save_project_full_path = asksaveasfilename(defaultextension="", filetypes=pmdt.pymod_session_extension, parent=self.main_window)
        if save_project_full_path == "":
            return None
        self.save_pymod_project(save_project_full_path)
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def sequence_save(self, element):
        """
        Save a single sequence to a file.
        """
        remove_indels_choice = False
        if "-" in element.my_sequence:
            remove_indels_choice = tkMessageBox.askyesno(message="Would you like to remove indels from the sequence when saving it to a file?", title="Save File", parent=self.main_window)

        filepath=asksaveasfilename(filetypes=[("fasta","*.fasta")],parent=self.main_window)

        if not filepath == "":
            dirpath = os.path.dirname(filepath)
            filename = os.path.splitext(os.path.basename(filepath))[0]
            self.build_sequences_file([element], filename, file_format="fasta", remove_indels=remove_indels_choice, use_structural_information=False, new_directory=dirpath)
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def save_full_model_to_file(self, full_model):
        save_file_full_path = asksaveasfilename(defaultextension = "", filetypes = [("PDB","*.pdb")], parent=pymod.main_window)
        if save_file_full_path != "":
            # Moves the saved file to the path chosen by the user.
            try:
                old_path = full_model.original_file_path
                os.rename(old_path, save_file_full_path)
            except:
                title = "File Error"
                message = "Could not save the alignment file to path: %s" % (save_file_full_path)
                self.show_error_message(title, message)
项目:firesave    作者:kactusken    | 项目源码 | 文件源码
def GetOutputPath():
    filename_SaveFile = tkFileDialog.asksaveasfilename(initialdir="C:\\", title="Select Output File Path",
                                                       filetypes=(("dat files", "*dat"), ("all files", "*.*")))
    ent_OutputFile.insert(0, filename_SaveFile)

# Function to print status updates to the text area
项目:FunKii-UI    作者:dojafoja    | 项目源码 | 文件源码
def export_to_batch(self):
        outf = filedialog.asksaveasfilename(defaultextension='.txt')
        if outf:
            with open(outf,'w') as f:
                for i in self.download_list:
                    f.write(i[1].strip()+'\n')
            message.showinfo('Complete','Done exporting batch job to file')
项目:constrained-writer    作者:enkiv2    | 项目源码 | 文件源码
def handleSaveAs(*args):
    global fname
    name=tkFileDialog.asksaveasfilename(initialfile=fname, filetypes=[('text', '.txt')])
    if(name):
        if(name!=fname):
            with open(name, 'w') as f:
                fname=name
                f.write(editBox.get(START, END).encode('utf8', 'replace'))
                top.wm_title("Constrained Writer: "+fname)
项目:mountain_tapir    作者:tttppp    | 项目源码 | 文件源码
def save(self):
        print('Save selected')
        outputFile = asksaveasfilename(defaultextension='.jpg')
        if outputFile is not None:
            outputImage = Image.new('RGB', (self.model.getWidth(), self.model.getHeight()))
            for region in self.model.getRegions():
                imageFile = self.model.regionToImageFile[region]
                if imageFile is None:
                    print('Warning: Region without image {0}'.format(region))
                    continue
                image = imageFile.getImageObject((region[2], region[3]), 'export')
                outputImage.paste(image, (region[0], region[1]))
            outputImage.save(outputFile)