Python Forum
[Tkinter] Syntax Highlighting in Text Editor
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Syntax Highlighting in Text Editor
#1
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.

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?
Reply


Messages In This Thread
Syntax Highlighting in Text Editor - by ShakeyPakey - Jun-09-2020, 06:43 PM
RE: Syntax Highlighting in Text Editor - by Larz60+ - Jun-09-2020, 06:45 PM
RE: Syntax Highlighting in Text Editor - by Yoriz - Jun-09-2020, 07:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Indentation for Tkinter-made Text Editor ShakeyPakey 4 5,229 Jun-08-2020, 03:13 PM
Last Post: menator01
  UTF8 for Urdu text editor technifire 2 3,668 Jul-24-2017, 11:15 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020