Tkinter question: position cursor within text widget

Fredrik Lundh fredrik at
Sun Jan 5 16:39:59 CET 2003

"v.wehren" <v.wehren at> wrote:

> After loading the contens of a text file into a text widget with something
> like: <snip>
>      content =
>      self.textbox.insert(END, content)
>      self.textbox.focus_set()
>       </snip>
> I want the insert cursor to be at the home position after the file has
> loaded.Is there a simple method to position the cursor at a given index? I
> haven't *found* any in the "prevailing" Tkinter sources across the web
> yet...

the cursor is represented by a predefined mark called INSERT.  to
move it around, use the mark_set method:

    self.textbox.mark_set(INSERT, 1.0)

more information here:
    (click on "Concepts" and scroll down to "Marks")


More information about the Python-list mailing list