How to get the contents of last line in tkinter text widget (Python 3) How to get the contents of last line in tkinter text widget (Python 3) tkinter tkinter

How to get the contents of last line in tkinter text widget (Python 3)


You can apply modifiers to the text widget indicies, such as linestart and lineend as well as adding and subtracting characters. The index after the last character is "end".

Putting that all together, you can get the start of the last line with "end-1c linestart".


Test widget has a see(index) method.text.see(END) will scroll the text to the last line.