Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
 
PREVIOUS NEXT
Tagged: #save #file #python #tkinter
ADD COMMENT
Topic
Name
4+6 =