Answers for "tkinter linux save file"

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

Python Answers by Framework

Browse Popular Code Answers by Language