Python tkinter.filedialog.asksaveasfile() Examples

The following are 10 code examples of tkinter.filedialog.asksaveasfile(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter.filedialog , or try the search function .
Example #1
Source File: keyboard_gui.py    From synthesizer with GNU Lesser General Public License v3.0 7 votes vote down vote up
def save_preset(self):
        file = asksaveasfile(filetypes=[("Synth presets", "*.ini")])
        cf = ConfigParser(dict_type=collections.OrderedDict)
        # general settings
        cf.add_section("settings")
        cf["settings"]["samplerate"] = str(self.samplerate_choice.get())
        cf["settings"]["rendering"] = self.rendering_choice.get()
        cf["settings"]["to_speaker"] = ",".join(str(v+1) for v in self.to_speaker_lb.curselection())
        cf["settings"]["a4tuning"] = str(self.a4_choice.get())
        # oscillators
        for num, osc in enumerate(self.oscillators, 1):
            section = "oscillator_"+str(num)
            cf.add_section(section)
            for name, var in vars(osc).items():
                if name.startswith("input_"):
                    cf[section][name] = str(var.get())
        # adsr envelopes
        for num, flter in enumerate(self.envelope_filter_guis, 1):
            section = "envelope_"+str(num)
            cf.add_section(section)
            for name, var in vars(flter).items():
                if name.startswith("input_"):
                    cf[section][name] = str(var.get())
        # echo
        cf.add_section("echo")
        for name, var in vars(self.echo_filter_gui).items():
            if name.startswith("input_"):
                cf["echo"][name] = str(var.get())
        # tremolo
        cf.add_section("tremolo")
        for name, var in vars(self.tremolo_filter_gui).items():
            if name.startswith("input_"):
                cf["tremolo"][name] = str(var.get())
        # arpeggio
        cf.add_section("arpeggio")
        for name, var in vars(self.arp_filter_gui).items():
            if name.startswith("input_"):
                cf["arpeggio"][name] = str(var.get())

        cf.write(file)
        file.close() 
Example #2
Source File: savefile.py    From Endless-Sky-Mission-Builder with GNU General Public License v3.0 6 votes vote down vote up
def save_file():
    """This method saves the data to a mission file"""
    #TODO: Expand this to save every part of the mission file:
    #   - Comments/Copyright
    #   - Mission
    #   - Events
    logging.debug("Saving selected file...")
    compile_mission()

    f = filedialog.asksaveasfile(mode='w', defaultextension=".txt")
    if f is None:  # asksaveasfile return `None` if dialog closed with "cancel".
        return

    for item in config.mission_file_items.items_list:
        f.write(item.to_string())
        f.write("\n\n\n")       # add whitespace between missions, per the Creating Missions guidelines
    f.close()

    logging.debug("Done.")
# end save_file 
Example #3
Source File: py_recorder.py    From Awesome-Python-Scripts with MIT License 6 votes vote down vote up
def stop(self):
        self.__is_recording=False
        file = filedialog.asksaveasfile(defaultextension="*.*", filetypes=[('mp4', '.mp4'),])
        if file:
            if file.name:
                print(file.name)
                shape = self.__temp_video_frames[0].shape
                print(shape)
                fourcc = VideoWriter_fourcc(*codec)
                video_writer = VideoWriter(file.name, fourcc, self.__frame_per_sec, (shape[1], shape[0]), True)
                if self.__temp_video_frames:
                    for frame in self.__temp_video_frames:
                        video_writer.write(frame)
                    del self.__temp_video_frames
                video_writer.release()
        self.__btn_start_stop.configure(text=btn_start_txt, command=self.start_recording, bg='green')
        self.__cmb_box['state']='normal' 
Example #4
Source File: chapter4_04.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 6 votes vote down vote up
def save_file(self):
        contents = self.text.get(1.0, tk.END)
        new_file = fd.asksaveasfile(title="Save file", defaultextension=".txt",
                                filetypes=(("Text files", "*.txt"),))
        if new_file:
            new_file.write(contents)
            new_file.close() 
Example #5
Source File: gui_main.py    From PlotIt with MIT License 5 votes vote down vote up
def save_file():
    file=fdialog.asksaveasfile(mode="wb", title="Save Figure", defaultextension=".png", filetypes = (("png files","*.png"),("all files","*.*")))
    if file is None:
        return None
    img_to_save=open(".temp/generated_plot.png","rb").read()
    file.write(img_to_save)
    file.close() 
Example #6
Source File: gb_ide.py    From greenBerry with Apache License 2.0 5 votes vote down vote up
def save_as_command(self, event=0):
        file = filedialog.asksaveasfile(
            mode="w",
            defaultextension=".gb",
            filetypes=(("greenBerry files", "*.gb"), ("All files", "*")),
        )
        if file != None:
            self.parent.title("greenBerry IDE" + " - " + file.name.replace("/", "\\"))
            self.file_dir = file.name
            data = self.txt.get("1.0", "end" + "-1c")
            file.write(data)
            file.close()
            self.old_text = self.txt.get("1.0", "end" + "-1c") 
Example #7
Source File: utils.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def _save(self):
        """ Save a file. """
        logger.debug("Popping Save browser")
        return filedialog.asksaveasfile(**self._kwargs) 
Example #8
Source File: select_path_dialog.py    From deepdiy with MIT License 5 votes vote down vote up
def select_save_path():
    root = Tk()
    root.withdraw()
    save_path =  filedialog.asksaveasfile(mode='a')
    root.destroy()
    return (save_path) 
Example #9
Source File: droneMapGUI.py    From pyparrot with MIT License 5 votes vote down vote up
def save_file_menu(self):
        """
        Bring up a save file dialog and then save
        :return:
        """
        filename = filedialog.asksaveasfile(initialdir=os.getcwd(),
                                            title="Save map file",
                                            defaultextension=".map")
        print("saving to ", filename.name)
        fp = open(filename.name, "wb")
        pickle.dump(self.scale_val, fp)
        pickle.dump(self.room_map, fp)
        fp.close() 
Example #10
Source File: GoogleArtDownloader.py    From google-art-downloader with GNU General Public License v3.0 5 votes vote down vote up
def file_save(name, status):
    path = status
    f = filedialog.asksaveasfile(mode='wb', defaultextension=".png", title="Saving picture", initialfile=name, filetypes=(("PNG high resolution image", "*.png"), ("all files", "*.*")))
    if f is None:
        lbl.config(text='Downloading was cancelled')
        btn.config(state='normal')
        return
    if os.path.abspath(path) != f.name.replace('/', '\\'):
        im = Image.open(path)
        im.save(f)
        os.remove(path)
        f.close()
        lbl.config(text='Success! File saved as : ' + str(status) + '!')
    else:
        lbl.config(text='Failed! Please next time don\'t replace file in script directory!')