Jun-09-2020, 06:43 PM
I am wondering if there is a way using the Python module tkinter to colour text, or do "syntax highlighting". I am making my own text editor using tkinter, and I want to check if the user types one of numerous keywords. If they do type a keyword, then the word is highlighted.
Is there any way I can check the text being written by the user in real-time, and when they type a keyword, then that word is highlighted?
If you are answering this, can you give me an example of the word "print" being highlighted in red?
class TextEditor: def __init__(self, master): master.title("Untitled - TextEditor") master.geometry("1200x700") self.textarea = tk.Text(master,font=("ubuntu",12))The code above contains the definition of the text area, which uses the tk.Text widget.
Is there any way I can check the text being written by the user in real-time, and when they type a keyword, then that word is highlighted?
If you are answering this, can you give me an example of the word "print" being highlighted in red?