DEV Community

Cover image for How To make a Text Editor in Python?
Kaveh Sabouri
Kaveh Sabouri

Posted on • Edited on

How To make a Text Editor in Python?

#Kaveh Sabouri
from tkinter import *
import time
window = Tk()
window.geometry("572x600")
window.config(bg="lavender")
window.title("Text-Editor")
frame1 = Frame(window,)
txt1= Text(window,font=("",10))
txt1.place(x=2,y=280)
labl1= Label(text="Click on the white field to write. ",font=("Lalezar",20),bg="lavender",fg="green")
labl1.place(x=140,y=239)
la1=Label(window,text="Background color:",font=("Lalezar",25),bg="lavender")
la1.place(x=355,y=2)
def red():
    txt1.config(bg="red")

#first
btn1=Button(window,text="Red",font=("",20),fg="red",command=red)
btn1.place(x=420,y=50)
def blue1():
    txt1.config(bg="Blue")
btn2=Button(window,text="Blue",font=("",20),fg="blue",command=blue1)
btn2.place(x=420,y=100)
def yellow1():
    txt1.config(bg="#ffe02e")
btn3=Button(window,text="Yellow",font=("",20),fg="#ffe02e",command=yellow1)
btn3.place(x=410,y=150)
def green1():
    txt1.config(bg="green")
btn4=Button(window,text="Green",font=("",20),fg="green",command=green1)
btn4.place(x=412,y=200)






#second
lala1=Label(window,text="Colored text:",font=("Lalezar",25),bg="lavender",fg="black")
lala1.place(x=190,y=2)
def fred():
    txt1.config(fg="red")
bbtnred=Button(window,text="Red",font=("",20),fg="red",command=fred)
bbtnred.place(x=230,y=50)
def blue2():
    txt1.config(fg="blue")
btn2=Button(window,text="Blue",font=("",20),fg="blue",command=blue2)
btn2.place(x=230,y=100)
def reset():
    txt1.config(fg="black")
    txt1.config(bg="white")
    txt1.config(font=("Arial"))
    window.geometry("572x600")


btnbargaedandan=Button(window,text="Reset",font=("",20),fg="red",command=reset)
btnbargaedandan.place(x=2,y=239)
def yxyx():
    txt1.config(fg="yellow")

btn8=Button(window,text="Yellow",font=("",20),fg="#ffe02e",command=yxyx)
btn8.place(x=223,y=150)
def green2():
    txt1.config(fg="green")
btn4=Button(window,text="Green",font=("",20),fg="green",command=green2)
btn4.place(x=225,y=200)


fontlable=Label(window,text="Sizes:",font=("Lalezar",25),bg="lavender",fg="black")
fontlable.place(x=50,y=2)
def size1():
    txt1.config(font=("",10))
bbtttnnn=Button(window,text="10",font=("",20),bg="lavender",fg="black",command=size1)
bbtttnnn.place(x=50,y=50)

def size2():
    txt1.config(font=("",20))
btn2=Button(window,text="20",font=("",20),command=size2)
btn2.place(x=50,y=100)
def size3():
    txt1.config(font=("",30))
btn3=Button(window,text="30",font=("",20),command=size3)
btn3.place(x=50,y=150)
window.mainloop()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)