Answers for "how to save data in python tkinter"

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 data in python tkinter"

Python Answers by Framework

Browse Popular Code Answers by Language