-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilesaving.py
More file actions
27 lines (22 loc) · 821 Bytes
/
filesaving.py
File metadata and controls
27 lines (22 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from tkinter import *
from tkinter import filedialog
def savefile():
file = filedialog.asksaveasfile(initialdir="/Users/briankimanzi/Documents/python/PycharmProjects/practice_lists",
defaultextension='.txt',
filetypes=[
("Text file", ".txt"),
("HTML file", ".html"),
("All files", ".*")
])
if file is None:
return
filetext = str(text.get(1.0, END))
# filetext = input("Enter some text i guess: ")
file.write(filetext)
file.close()
window = Tk()
button = Button(text='Save', command=savefile)
button.pack()
text = Text(window)
text.pack()
window.mainloop()