index in Tkinter text objects

Fredrik Lundh effbot at
Sat Sep 2 12:39:04 CEST 2000

Keagan Schopfer wrote::
> i am building a text editor using Tkinter, and i am wondering how i would
> find the current index of the insert currsor in a Text dialog. is there some
> function like text.get_current_index()?

the insert cursor has a symbolic name (INSERT), which
you can use everywhere Tkinter expects a buffer index.

to get the current line/column, use text.index(INSERT)
(this returns a string).  an example:

    # get line/column
    index = text.index(INSERT)

    # convert index to integers
    row, column = map(int, string.split(index, "."))

also see:


<!-- (the eff-bot guide to) the standard python library:

More information about the Python-list mailing list