I've an entry widget in my tkinter program. Let's say I typed about 10 words in it and went to another entry widget for typing. Now when I click back on my entry widget 1 (previous one), cursor goes to the character as per click position. How do I get cursor position index for that widget ? I referred to http://effbot.org/tkinterbook/entry.htm documentation but couldn't find a suitable method for getting cursor position.
Thanks.
You can use the Entry.index()
method to get the index of the current INSERT
position.
from Tkinter import *
def get_info():
print e.index(INSERT)
root = Tk()
e = Entry(root)
e.pack()
Button(root, text="get info", command=get_info).pack()
root.mainloop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With