Dynamically indenting and highlighting words in tkinter textbox Dynamically indenting and highlighting words in tkinter textbox tkinter tkinter

Dynamically indenting and highlighting words in tkinter textbox


Tkinter is quite well suited to this sort of thing. It's possible to make a very smart text editor if you're willing to put in some effort.

This answer shows how to get the text widget to fire an event whenever something in the text widget changes. It's a little complicated, but fairly foolproof.

If you want something simpler, you can simply bind on <Any-KeyRelease> which will fire an event whenever the user releases a key. You can then use the information in the event object to decide what to do. It won't handle the case where you cut and paste with the mouse, for example, and your binding will fire for arrow keys and other non-inserting keys, which is why I recommend the more complicated solution.

This answer shows an example of using a binding on <space> to do do a simple spellcheck, and also shows a fairly simplistic implementation of a toolbar with a "bold" button.