-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsave_file.py
More file actions
29 lines (22 loc) · 766 Bytes
/
save_file.py
File metadata and controls
29 lines (22 loc) · 766 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
28
29
from tkinter import *
from tkinter import filedialog
# Functions
def saveFile():
file = filedialog.asksaveasfile(defaultextension=".txt",title="Save the file as", filetypes=[("Text File", ".txt"), ("Python File", ".py")])
fileText = str(textarea.get("1.0", END))
file.write(fileText)
file.close()
# Creating Window
window = Tk()
# Styling Window
window.title("Save File Program Tkinter")
window.geometry("400x700")
window.config(bg="light yellow")
# Creating Save Button
saveBtn = Button(window, text="Save File", command=saveFile, font=("Ink Free", 15, "bold"))
saveBtn.pack(side=TOP)
# Creating Textarea
textarea = Text(window, font=("Ink Free", 15, "bold"))
textarea.pack()
# Displaying Window
window.mainloop()