Moving to a specific position in a text widget tkinter Moving to a specific position in a text widget tkinter tkinter tkinter

Moving to a specific position in a text widget tkinter


The text widget has marks, which are in effect named positions. The insertion cursor is defined by the mark "insert" (and the tkinter constant INSERT). You can move this index using the mark_set method.

For example, this moves the insertion cursor to line 3, character 14:

the_widget.mark_set("insert", "3.14")

If you want to make sure the new insert position is visible you can use the see method, which will scroll the widget enough for the given index to be visible:

the_widget.see("insert")