I am making a text editor in tkinter for code, and I want to loop through every single word in the ScrolledText, and then change the color of it depending which word it is, but how?
I've already searched it up and found nothing that helped me. I also tried it on myself but I didn't know how to loop through the words forever (since while True made the program stop responding) and I don't know how to change the text color for only one bit.
This is all the code of my editor, some variables are defined in different functions:
def bie_save():
bie_file_read = open(bie_file,"r")
contents = bie_file_read.read()
bie_file_read.close()
data = text_area.get("1.0",tk.END + "-1c")
bie_file_file = open(bie_file,"w")
bie_file_file.write(data)
bie_file_file.close()
def builtin_editor(file,protype,proname):
global bie_file
bie_file = file
bie = tk.Tk()
bie.title("FIDE - Editor")
bie.geometry("800x450")
global text_area
text_area = st.ScrolledText(bie,width=800,height=450)
text_area.pack()
bie_file_read = open(bie_file,"r")
contents = bie_file_read.read()
bie_file_read.close()
text_area.insert("1.0",contents)
menu = tk.Menu(bie)
bie.config(bg=bg_theme,menu=menu)
fileMenu = tk.Menu(menu)
menu.add_cascade(label="File",menu=fileMenu)
fileMenu.add_command(label="Save",command=bie_save)
fileMenu.add_separator()
fileMenu.add_command(label="Exit")
bie.mainloop()
I want it like when you type "pass" it changes to orange or something like that, but if you type something else it won't.