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


Python filedialog.asksaveasfile方法代码示例

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


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

示例1: save_file

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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 
开发者ID:shitwolfymakes,项目名称:Endless-Sky-Mission-Builder,代码行数:22,代码来源:savefile.py

示例2: save_preset

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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() 
开发者ID:irmen,项目名称:synthesizer,代码行数:43,代码来源:keyboard_gui.py

示例3: stop

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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' 
开发者ID:hastagAB,项目名称:Awesome-Python-Scripts,代码行数:19,代码来源:py_recorder.py

示例4: save_file

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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() 
开发者ID:NITDgpOS,项目名称:PlotIt,代码行数:9,代码来源:gui_main.py

示例5: save_as_command

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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") 
开发者ID:Abdur-rahmaanJ,项目名称:greenBerry,代码行数:15,代码来源:gb_ide.py

示例6: _save

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
def _save(self):
        """ Save a file. """
        logger.debug("Popping Save browser")
        return filedialog.asksaveasfile(**self._kwargs) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:6,代码来源:utils.py

示例7: select_save_path

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
def select_save_path():
    root = Tk()
    root.withdraw()
    save_path =  filedialog.asksaveasfile(mode='a')
    root.destroy()
    return (save_path) 
开发者ID:deepdiy,项目名称:deepdiy,代码行数:8,代码来源:select_path_dialog.py

示例8: save_file

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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() 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:9,代码来源:chapter4_04.py

示例9: save_file_menu

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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() 
开发者ID:amymcgovern,项目名称:pyparrot,代码行数:15,代码来源:droneMapGUI.py

示例10: file_save

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import asksaveasfile [as 别名]
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!') 
开发者ID:mewforest,项目名称:google-art-downloader,代码行数:17,代码来源:GoogleArtDownloader.py


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