save file python tkinter

Solutions on MaxInterview for save file python tkinter by the best coders in the world

showing results for - "save file python tkinter"
Gloria
07 Sep 2017
1from tkinter import filedialog
2from tkinter import *
3
4win = Tk()
5filename = filedialog.asksaveasfilename(initialdir='/', title='Save File', filetypes=(('Text Files', 'txt.*'), ('All Files', '*.*')))
6textContent = "I'm the text in the file"
7myfile = open(filename, "w+")
8myfile.write(textContent)
9# to test
10print("File saved as ", filename)