7

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.

dhruvvyas90
  • 1,135
  • 1
  • 15
  • 31

1 Answers1

12

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()
martineau
  • 119,623
  • 25
  • 170
  • 301
tobias_k
  • 81,265
  • 12
  • 120
  • 179
  • Perfect. That's what I was looking for. I'm new to tkinter and hence couldn't understand while reading its description. – dhruvvyas90 Jun 24 '15 at 10:36