Answers for "how to save as in tkinter library in python"

2

save file python tkinter

from tkinter import filedialog
from tkinter import *

win = Tk()
filename = filedialog.asksaveasfilename(initialdir='/', title='Save File', filetypes=(('Text Files', 'txt.*'), ('All Files', '*.*')))
textContent = "I'm the text in the file"
myfile = open(filename, "w+")
myfile.write(textContent)
# to test
print("File saved as ", filename)
Posted by: Guest on January-20-2021

Code answers related to "how to save as in tkinter library in python"

Python Answers by Framework

Browse Popular Code Answers by Language