I'm trying to find a reliable way of getting the current cursor position in a tkinter text widget.
What I have so far is:
import tkinter as tk
def check_pos(event):
print(t.index(tk.INSERT))
root = tk.Tk()
t = tk.Text(root)
t.pack()
t.bind("<Key>", check_pos)
t.bind("<Button-1>", check_pos)
root.mainloop()
However, this prints the previous cursor position and not the current one. Anyone have any ideas what is going on?
Thanks in advance.