from tkinter import *
from tkinter import font, filedialog
def saveDoc(): #saves the document
global textarea
text=textarea.get("1.0","end-1c")
location=filedialog.asksaveasfilename()
file=open(location,"w+")
file.write(text)
file.close()
## creating different functions to change font and bold text
def Algerian():
global textarea
textarea.config(font="Algerian")
def Arial():
global textarea
textarea.config(font="Arial")
def Courier():
global textarea
textarea.config(font="Courier")
def Cambria():
global textarea
textarea.config(font="Cambria")
def boldDoc():
global textarea
textarea.config(font=('arial',14,'bold'))
## creating GUI
root=Tk()
root.title("notepad by sethi")
## creating and configuring save button
savebtn=Button(root,command=saveDoc,text="Save")
savebtn.grid(row=1,column=0)
savebtn.config(font=('arial',20,'bold'),bg="DodgerBlue2",fg="white")
## creating and configuring font menu button
fontbtn=Menubutton(root,text="Font")
fontbtn.config(font=('arial',20,'bold'),bg="DodgerBlue2",fg="white")
fontbtn.grid(row=1,column=1)
fontbtn.menu=Menu(fontbtn,tearoff=0)
## creating and configuring drop down menu for fontbutton
fontbtn["menu"]=fontbtn.menu
fontbtn.menu.add_checkbutton(label="Arial",
command=Arial)
fontbtn.menu.add_checkbutton(label="Algerian",
command=Algerian)
fontbtn.menu.add_checkbutton(label="Cambria",
command=Cambria)
fontbtn.menu.add_checkbutton(label="Courier",
command=Courier)
## creating and configuring bold text button
boldbtn=Button(root,command=boldDoc,text="Bold")
boldbtn.grid(row=1,column=2)
boldbtn.config(font=('arial',20,'bold'),bg="DodgerBlue2",fg="white")
textarea=Text(root)
textarea.grid(row=2,columnspan=5)