Tkinter.Text widget - how to get text cursor position?

Alex9968 noname9968 at gmail.com
Wed Mar 19 20:07:26 CET 2008


Alex9968 wrote:
> Is it possible to get position (in numbers) of the insertion cursor? As 
> I understood, Text widget uses mark named INSERT to store it, which is 
> available globally by just referencing INSERT, but how could I get 
> actual coordinate numbers of the mark?
> I need this because I want not just to insert string at, but to examine 
> text before and after the insertion cursor. I can probably use .get() to 
> extract the halves of text before and after cursor, but it'd be better 
> just to know the position.
>
> Thanks
It's .index()

Problem was that it's missed in Tkinter reference: a GUI for Python



More information about the Python-list mailing list